Bytes & Bobs

Migrating to Hugo From Zola

I’m not sure what percentage of this site is dedicated to itself, but it’s probably much higher than it should be.

Since 2021, this site has used the static site generator (herein “SSG”) Zola. I like Zola a lot and spent some time, particularly early on, bending it to my will. As I’ve posted a little less frequently however, I’ve noticed that every time I want to write something new, I spend at least half the time fixing whatever changed in Zola/Tera rather than writing. I don’t have the Rust etc. set up, so typically just grab Zola from Flathub, so I’m beholden to the versions there, rather than pinning a specific version.

Yes, I’m aware it wouldn’t be that difficult to get a pinned version.

But 5 years is a long time, so time for a change. This time, it’s Hugo’s turn. I deliberately didn’t choose Hugo last time and the reason is the same reason I am choosing it this time. It’s written in Go and uses Go’s templating. I’m a Go developer (amoungst other things) - previously I wanted the things I do outside of work to be as unrelated as possible; now however, I just want it to work! What would take me an hour to work out with Zola will probably only take 10 minutes with Hugo, so here we are.

The migration itself was actually not too bad. The structure and formatting/frontmatter for content is almost identical between the two SSGs. All I did was:

  1. Modify a few org-mode drafts so they weren’t published with #+DRAFT: true (Hugo supports org-mode for content).
  2. Make Go versions of the shortcodes I was using (primarily for images) and change in in-content markup (effectively {{ post_image ... }} became {{< post_image ... >}}).

Other than that, I broadly followed the quickstart in a new directory:

  1. hugo new project migrate
  2. hugo new theme basic
  3. hugo --buildDrafts

Then it was just a case of getting to grips with the theme layouts and template variables Hugo uses, updating the themes and pages and fiddling with the config a bit. Naturally, this was all made much simpler by the fact that this site is small, and I didn’t use that many Zola features.

One breaking change I’ve made is is moving posts into a /posts prefix. I will sort out redirects at some point.

Tags: