RSS Amplifier

Martin's Blog · Jan 31, 2021

Using Hugo Theme Modules With Netlify

0
Sign in to vote or save

Martin Stemplinger · Martin's Blog

This blog runs on hugo so I try to make use of hugo features. According to the hugo website modules are now recommended to insert content into a hugo site a simple and useful example being a theme.

Since I use my personal fork of the minimal theme I decided to try this out. It’s quite easy to do.

The main steps are:

  • install Go
  • run hugo mod init <module name> in the top directory. I just used myblog as name which worked. This creates a go.mod file.
  • change the config.toml entry for the theme to simply point to the repo. In my case the entry is theme = github.com/Bassmann/minimal. The hugo documentation recommends to also add this as a module but it seems to work also without it.

Local testing worked fine which creates also a go.sumfile. So I happily commited and pushed the content and the new files. Unfortunately the deployment at Netlify failed and I got confused.

The solution however is simple enough: Netlify needs to be told to install go as part of the build. This is turn only requires to add an environment variable called GO_VERSION with the value of the go version you want to use. In my case it’s 1.15.7. With this change everything works as intended.

Read the original on mstempl.netlify.app

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.