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

Are there plans to add a newer version of Hugo?

The recently released v0.116.0 adds support for regex in the where function which is really helpful for filtering pages in a theme.

And v0.110.0 added findresubmatch which makes it easier to work with matches from a regex.

Yes, I’ve been meaning to add a newer version. I’ll do that soon. It will probably be an option but not the default until we can make sure all the themes work with it.

1 Like

Hugo 0.117 has now been added as an option. The default is still 0.91 for now. You can change your blog’s version of Hugo on the Design page.

3 Likes

Hi! This post mentions a getting started guide for local theme development. I’ve been looking for exactly that, as I’d like to work on templates locally before presumably pushing them to GitHub and finally clicking the button to resync in micro.blog

But I haven’t found any information about local theme dev apart from this post. Could someone point me in the right direction?

Hi @agriffis — my approach has been

  1. Install Hugo locally (make sure the version you install matches the Hugo version in the Micro.blog dashboard at DesignHugo version
  2. Set up a git repo with the Micro.blog/Hugo template you want to use for your blog
  3. Export your template from Micro.blog
    1. Click the circle w/ the ellipsis on one of the Micro.blog dashboard pages that has your blog’s domain at the top (like Posts or Design)
    2. Click Export
    3. Click Export theme and Markdown
  4. Wait for the email w/ a link to download the files for your blog, download, and unzip it
  5. Copy the “content” folder from the export over the content folder in your local theme repo
  6. Run hugo serve in your local repo to start the Hugo dev server
  7. Adjust your templates
  8. Commit and push to GitHub
  9. Click the sync button under Design → Edit Themes → Theme Name to sync
  10. Micro.blog will rebuild your site w/ the latest changes
1 Like