Create Website With Blog Using Hugo on Windows

Hugo is a popular open-source static site generator (SSG) that’s known for its speed, flexibility, and ease of use. In this post, I’ll walk you through the process of creating a website using Hugo on Windows.
Installing Hugo
Using winget
-
Install Hugo:
- Open PowerShell as an administrator.
- Run
winget install Hugo.
-
Verify Installation:
- Run
hugo versionin PowerShell to verify the installation.
- Run
Manual Installation
-
Download Hugo:
- To install Hugo, you can clone the repository:
git clone https://github.com/gohugoio/hugo.git. - Alternatively, for the latest release, visit Hugo Releases. Download the appropriate version and extract
hugo.exe.
- To install Hugo, you can clone the repository:
-
Set Up Hugo:
- Place
hugo.exein a preferred location, such asC:\hugo\bin. - Add the path of
hugo.exeto your system’s environment variables.
- Place
-
Verify Installation:
- Open PowerShell and run
hugo versionto verify the installation.
- Open PowerShell and run
-
Alternative Setup:
- If you prefer, you can keep
hugo.exein your project directory. In this case, use.\hugo versionto check the version.
- If you prefer, you can keep
Creating a Website
-
Initiate a New Website:
- Run
hugo new site <website-name>to create a new folder named<website-name>.
- Run
-
Choose a Theme:
- Visit Hugo Themes to download a theme of your choice.
- Extract the theme and place it in the
<website-name>/themesfolder.
-
Configure the Website:
- Edit the
config.tomlfile inside your<website-name>folder. You can use this sample config file as reference.
1 2 3 4baseURL = 'https://www.example.com/' # provide valid url languageCode = 'en-us' title = 'Website Name' theme = "hermit" - Edit the
-
Preview the Site:
- Run
hugo serverto preview the website locally. Even if you provide a baseURL for a remote host, it will run locally.
- Run
-
Generate the Static Website:
- Create a folder named public.
- Run
hugo -t <theme-name>to generate the static website, which will be stored in the public folder.
-
Deploy the Website:
- Transfer the files from the public directory to the public directory of your chosen web hosting service.
Creating a Post or Page
- To create a new post, run hugo new posts/
.md. This will create a markdown file for your post in the content/posts folder. - Edit the markdown file to add your content using your preferred text editor.
- To create a new page, run hugo new
.md. The markdown file will be created in the content folder. - Again, edit the markdown file to add content for your page.
- Font Awesome icons can be added using
:(fas fa-<icon-name> fa-fw): - When linking images in your markdown file in relation to your post, take into account the structure of the leaf bundle directory, as shown below.
|
|
Hosting Hugo Website on GitHub Pages
-
Create a GitHub Repository:
- Create a new repository on GitHub with the name
<username>.github.io.
- Create a new repository on GitHub with the name
-
Initialize Git:
- Run
git initin your project directory. - Add the GitHub repository as a remote: `git remote add origin
- Run
-
Generate the Website:
- Run
hugo -t <theme-name>to generate the static website.
- Run
-
Push to GitHub:
- Push the generated files to the GitHub repository:
git push -u origin main.
- Push the generated files to the GitHub repository:
-
Enable GitHub Pages:
- Go to the repository settings on GitHub.
- Under the GitHub Pages section, select the main branch as the source.
-
Access the Website:
- Visit
https://<username>.github.ioto access your Hugo website.
- Visit
Hugo FixIt Themes Installation
Hugo offers a wide range of themes that you can use to customize your website. One of my favorite themes is LoverIt, which offers a clean and modern design. However, there is a bug-fixed version of LoverIt called FixIt.
To use the FixIt theme, you can follow these steps:
- Clone the FixIt repository into the themes folder of your Hugo project.
|
|
- To use the FixIt theme, update the theme field in your
config.tomlfile.
|
|
-
Run
hugo serverto preview your website with the FixIt theme. -
To generate the static website with the FixIt theme, run
hugo -t FixIt. -
Push the changes to your GitHub repository to update your website with the FixIt theme.