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 usedmyblog
as name which worked. This creates ago.mod
file. - change the
config.toml
entry for the theme to simply point to the repo. In my case the entry istheme = 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.sum
file. 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.