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

  1. Install Hugo:

    • Open PowerShell as an administrator.
    • Run winget install Hugo.
  2. Verify Installation:

    • Run hugo version in PowerShell to verify the installation.

Manual Installation

  1. 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.
  2. Set Up Hugo:

    • Place hugo.exe in a preferred location, such as C:\hugo\bin.
    • Add the path of hugo.exe to your system’s environment variables.
  3. Verify Installation:

    • Open PowerShell and run hugo version to verify the installation.
  4. Alternative Setup:

    • If you prefer, you can keep hugo.exe in your project directory. In this case, use .\hugo version to check the version.

Creating a Website

  1. Initiate a New Website:

    • Run hugo new site <website-name> to create a new folder named <website-name>.
  2. Choose a Theme:

    • Visit Hugo Themes to download a theme of your choice.
    • Extract the theme and place it in the <website-name>/themes folder.
  3. Configure the Website:

    • Edit the config.toml file inside your <website-name> folder. You can use this sample config file as reference.
    1
    2
    3
    4
    
    baseURL = 'https://www.example.com/' # provide valid url
    languageCode = 'en-us'
    title = 'Website Name'
    theme = "hermit"
  4. Preview the Site:

    • Run hugo server to preview the website locally. Even if you provide a baseURL for a remote host, it will run locally.
  5. 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.
  6. 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.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

content
 \__posts 
 |  \__post_about_blah
 |  |  |--index.md
 |  |  |--picture_1.jpg
 |  |  \__images
 |  |  |  |--picture_2.jpg               
 |  |  |  |--picture_3.jpg      
 |  \__blah_blah_post
 |  |  |--index.md
 |  |  |--picture_1.jpg
 |  |  \__images
 |  |  |  |--picture_2.jpg               
 |  |  |  |--picture_3.jpg    

Hosting Hugo Website on GitHub Pages

  1. Create a GitHub Repository:

    • Create a new repository on GitHub with the name <username>.github.io.
  2. Initialize Git:

    • Run git init in your project directory.
    • Add the GitHub repository as a remote: `git remote add origin
  3. Generate the Website:

    • Run hugo -t <theme-name> to generate the static website.
  4. Push to GitHub:

    • Push the generated files to the GitHub repository: git push -u origin main.
  5. Enable GitHub Pages:

    • Go to the repository settings on GitHub.
    • Under the GitHub Pages section, select the main branch as the source.
  6. Access the Website:

    • Visit https://<username>.github.io to access your Hugo website.

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:

  1. Clone the FixIt repository into the themes folder of your Hugo project.
1
git clone git clone https://github.com/hugo-fixit/FixIt.git themes/FixIt
  1. To use the FixIt theme, update the theme field in your config.toml file.
1
theme = "FixIt"
  1. Run hugo server to preview your website with the FixIt theme.

  2. To generate the static website with the FixIt theme, run hugo -t FixIt.

  3. Push the changes to your GitHub repository to update your website with the FixIt theme.

0%