Skip to main content

Hugo Static Site Generator

There are plenty of static site generators out there: Hugo, Jekyll, Ghost, Gatsby, are just a few popular ones. I've grown to like Hugo as I've found it's speed to be unmatched. To get started, simply follow their installation docs! I'll summarize shortly how I did it below:

Installation

To install hugo from the source with a packet manager, run the following command in your terminal or CMD prompt window:

winget install Hugo.Hugo.Extended

To use Hugo and all of its functionality, you'll also need to install Git and Go version 1.20 or higher. Configure your global username and email for Git, and you should be all set.

Github

For version control, I've created 2 Repositories in Github, as I use Github pages for deploymen:

  • githubhusername.github.io
    • This will be my static repository where all of my html files will be uploaded to and will be used for deployment workflows. This is a public repository.
  • website
    • This is my "active" repository, where I'll store my hugo website. This is a private repository.
Create a Site

To create a site with Hugo, CD to where you want to store the site, in my case, I've cloned my "website" repository to my laptop. I changed directory into that cloned repository and ran the command:

hugo new site nameofsite
Theme Selection

There are hundred of prebuilt themes to use, with endless customization. If you're familiar with HTML/CSS, you can customize a theme even further, as I did. Select a theme, then run the following command in your root directory of your website:

git submodule add https://githubrepolinkhere themes/theme-name
echo "theme = 'theme-name'" >> hugo.toml
Build & Deployment

By default running the "hugo" command will generate static files for your website and store them in a folder titled "Public" in your website directory. You'll want to add this as a github submodule to your public static repository. To do this, change directory to your website, and run the following command:

git submodule add -b https://githubrepolinkhere public

Now, you should be able to make edits and commit your changes to both repositories.