By adopting zola as a go-to Static Site Generator (SSG) tool I was successfully able to leave the Sapper behind. There was however quite a serious issue with the new blog setup that went unnoticed for a few days.

Precisely, the problem was with the URL links. It is very important to keep URLs the same, or at least to arrange a proper redirect. Other URL insights I made are also available in this post. The problem was that the new links looked like this:

https://peterbabic.dev/upgrading-wiringpio-raspberry-pi-4/

But the original links looked like this:

/blog/upgrading-wiringpio-raspberry-pi-4/

See? The URL was missing the blog/ part segment, I decided to call prefix here, for the lack of better word at hand. Word at hand? Whatever.

The symptom

I have actually found about the problem by accident, trying to paste some links on the social media but I was getting a 404 on the links I got from the browser's address bar. I knew they should be fine, as I must have had visited them before, since they browser history had an entry.

At first I thought that maybe my server is down, but everything other there was up and running. Then blog homepage was also running, and clicking the links to individual posts was working, yet the address bar links were dead. And then it clicked.

Adding an URL prefix

Realizing that this is quite serious, I stopped what I was doing and started figuring out how to fix this in Zola. I needed to add the blog/ segment there, but no actual configuration setting seemed to elude me.

Of course, there was no configuration, I had to actually move the files from the content/ directory to the /content/blog and then arrange for the rest. After struggling for a bit, the solution came:

  • Move the original _index.md now residing in content/blog/_index.md one level up, back into now devoid content/:
+++
sort_by = "date"
paginate_by = 7
+++
  • Create another _index.md in its original place at content/blog/_index.md:
+++
transparent = true
redirect_to = "/"
+++

Simple, right? Now all the links are as they were before the conversion from Sapper to Zola. The redirect option is not entirely necessary, but nice to have. The most important bit is the transparent = true. It basically shifts the responsibility to the _index.md one level up.

There are links below that discuss what the transparent option does, as I am still not quite that certain and for now I find the nomenclature chosen (transparent, huh?) very confusing, so go read that to gain even better insight. Happy writing.