I’ve moved this blog from Gatsby.js to Hugo. My build times have gone down from more than 7 minutes to a few seconds!

The slow build times with Gatsby have been an ongoing concern for me. I’ve slowly been creeping towards Netlify’s free 300-minutes-build-time cap.

Hugo runs a magnitude faster, and it integrates well with Netlify.

Hugo is a static site generator built with Golang. The project’s selling points are incredible speed, ease of use, and the ability to configure tons of settings.

You don’t need to know Golang to make it work.

Here’s a practical guide on creating a website with Hugo and deploying it to Netlify.

How To Move To Hugo

Create Hugo Site

Install Hugo

Prerequisites: Git

The Installation Guide offers a good overview.

I’ll provide some examples, but if you don’t find your operating system here, you should check out the official instructions.

brew install hugo
sudo apt-get install hugo
Arch Linux
sudo pacman -Syu hugo

Create Hugo Project

hugo new site <project-name>

The command will create a new Hugo site. Navigate inside that directory.


hugo new site netlify-blog
cd netlify-blog

Add A Theme

Go to and choose a theme.

You should add the theme to your site with a Git Submodule. This approach works best with Netlify.

Let’s say your project is called netlify-blog, and you want to install the Kiera theme:

cd netlify-blog

## initialize Git
git init
## add theme via submodule
git submodule add themes/kiera

Configure Theme

Most themes offer an example configuration. Check their documentation. The configuration file is called config.toml.

Here’s an example for the Kiera theme:

pygmentsCodeFences = true

disqusShortname = "" #Disqus shortname
googleAnalytics = "" #Google Analytics ID

theme = "kiera"

    name = ""       #Author name
    github = ""     #Github username
    gitlab = ""     #Gitlab username
    linkedin = ""   #LinkedIn username
    facebook = ""   #Facebook username
    twitter = ""    #Twitter username
    instagram = ""  #Instagram username

    tagline = "the tagline for this website"
    customCSS = []  #Optional Customised CSS
    contentTypeName = "posts"


Customize Theme

There’s one trick you can use to add some minimal customization to your theme, but still be able to update the theme via git submodules.

Create a new folder in the themes directory - for example, kiera-customized.

Let’s say you want to edit the way the theme processes your post front-matter. Each theme has a folder called archetypes, which contains a template. (See Archetypes for a detailed explanation.)

Here’s how Kiera’s template for posts looks like (themes/kiera/archetypes/

title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
tags = []
categories = []

My front-matter for Gatsby looked like this:

title: "Modern JavaScript"
date: "2019-11-17"
  - JavaScript
  \- Tutorial

Let’s copy that format to our customized theme folder.

cd themes/kiera-customized

Edit that file:

title: ""
date: ""
  - ""
  - ""

Add the customized theme to the config.toml:

theme = ["kiera-customized", "kiera"]

Now all your previous blog posts, which use a different format for the front-matter, will still work.

URL Management

If you want to adjust how Hugo serves your URLs, you can set a permalink configuration to netlify.toml:

  posts = "/:year/:month/:title/"

Check the docs for more options.

Add Content

Add Markdown posts to the content folder.

You can use the hugo command for that:

hugo new posts/

The command will create a Markdown file with meta-data.

Or you can manually add a file and provide the front-matter.

Development Server

Run the development server with hugo server -D.

Netlify Configuration

You should check the guide on hosting on Netlify.

But for now, let’s create a netlify.toml file:

publish = "public"
command = "hugo --gc --minify"

HUGO_VERSION = "0.59.1"
HUGO_ENV = "production"

command = "hugo --gc --minify --enableGitInfo"

HUGO_VERSION = "0.59.1"
HUGO_ENV = "production"

command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"

HUGO_VERSION = "0.59.1"

command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"

HUGO_VERSION = "0.59.1"


Source Control And Automatic Deploys With Git


Netlify works with several Git providers like GitHub, GitLab and Bitbucket.

Choose your favorite provider and create a repository.

Here’s a guide for GitHub: Create a repo.

Commit your Hugo project and push it to the remote repository.

Example .gitignore:


Netlify Dashboard

Follow the steps on Host on Netlify to connect your Git repository to Netlify.

We’ve already configured the Hugo version for Netlify in the previous step.

If you’ve already setup a previous project with Netlify that you would like to replace, you can do that in your Netlify Dashboard. Go to your project, “Deploys” > “Continous Deployment”. You can change the Git repository, build command and publish directory.

The build command is hugo --gc --minify. The default build directory is public.

Netlify Pitfalls

You’ll most likely need the extended version of Hugo. That’s the version that comes with most installations. And it’s also the version that works with SASS.

Go to your Netlify dashboard and open your project. Go to “Deploy Settings” > “Build image selection”.

Make sure you choose Ubuntu Xenial 16.04 if it isn’t already selected.

Further Reading