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 incontent/blog/_index.md
one level up, back into now devoidcontent/
:
+++
sort_by = "date"
paginate_by = 7
+++
- Create another
_index.md
in its original place atcontent/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.
Links
- https://www.getzola.org/documentation/content/section/#front-matter
- https://www.xypnox.com/blag/posts/migrating-to-zola/
- https://estada.ch/2021/3/28/blog-bugs-not-migrating-to-zola-for-now/
- https://zola.discourse.group/t/how-to-paginate-a-subdirectory/749
- https://github.com/getzola/zola/issues/408
- https://github.com/getzola/zola/issues/1430