Hugo version & theme development

I wanted to start work on my own theme, but per the getting started guide, brew install hugo installs v0.105 and there doesn’t seem to be an easy way to install a specific version without creating a tap

There are a bunch of incompatabilities between v0.105 and v0.91, so if I’m going to do local development it should definitely be the same version that micro.blog is using.

Does anyone have any updated instructions on the best way to get the right hugo version on a mac?

1 Like

I haven’t done this lately, but I think the best way is to download a specific version directly rather than use Brew:

https://github.com/gohugoio/hugo/releases/download/v0.105.0/hugo_0.105.0_darwin-universal.tar.gz

Then drop that in /usr/local/bin or wherever.

I think we should also add the latest Hugo as an option in Micro.blog, but that may take longer.

From my testing there were a bunch of deprecations in hugo that they finally got around to removing that will end up breaking a lot of templates. Still worth doing, but just a heads up…

If you are comfortable with Docker, using an image might be even easier:

With docker installed “installing” and using hugo would come down to running this on the command line (e.g. for v.0.91):

docker run --rm -it \
  -v $(pwd):/src \
  -p 1313:1313 \
  klakegg/hugo:0.91.0 \
  version

The result looks like this in the shell (for the first time, second time the image exists already locally and doesn’t get pulled again):

docker run --rm -it \
  -v $(pwd):/src \
  -p 1313:1313 \
  klakegg/hugo:0.91.0 \
  version
Unable to find image 'klakegg/hugo:0.91.0' locally
0.91.0: Pulling from klakegg/hugo
24fb2886d6f6: Pull complete 
08793e71de36: Pull complete 
05e78297df53: Pull complete 
Digest: sha256:1dffab8fcffb0f7b887c9f2120f71deb5b7123267c3a8f6becda5864d35b82ba
Status: Downloaded newer image for klakegg/hugo:0.91.0
hugo v0.91.0-D1DC0E9A linux/amd64 BuildDate=2021-12-17T09:50:20Z VendorInfo=gohugoio

The first part (docker run…) is the docker setup/config part and the last part (version) is the hugo command you want to run in the current directory (could be server or something else (the server should be reachable under localhost:1313 this way), leave that part out if you just want a normal build). Think of the first part as typing hugo in the shell and the last part as the subcommand that naturally follows.

P.S.: The command used here could be simplified and you could use dockcer-compose. But if you know that you don’t need more info than that a docker image exists. This was just meant to give people a little help if they don’t know their way around the docker ecosystem, yet.

1 Like