So I fixed my blog again
I’ve mentioned that some pages of my blog haven’t been working. I’ve since fixed those pages and reinforced two pre-existing notions of mine: first, AI (LLMs specifically) can be a great tool if you use it to learn and enhance your existing skills; second, my blog writing is more important than I realized.
What went wrong
As you may know, if you visit my blog (though I realize most of you probably read this via RSS readers), I have several pages on my blog (which effectively make it a website, right? Are all blogs websites? 🤔). Some of those correspond to categories (such as my Emacs org-mode page or my movie reviews), while others are informative, like my about page and archive, which also include a search option for the site. You know, the basic blog-owner stuff.
My website is hosted by Micro.blog, which utilizes Hugo to build its sites. I switched to Tiny Theme, which is made especially for Micro.blog and comes with a few extra features, two years ago. These features, called Microhooks, can further customize the theme if you’re willing to make a few technical adjustments.
In my case, I use Microhooks on some of the pages. The archive page, which displays categories and all posts by day by default, was modified to include the search plugin and additional information I added before the default page starts. Then, for the Emacs org-mode category, there’s an introductory text with an image I created a while back, and then the rest of the post that fits into that category.
About a week ago, those Microhooks stopped working. The pages I mentioned displayed the default theme, as if I never customized them with Microhooks.
The fix
I struggled for a couple of days trying to figure out what went wrong. I thought a recent update to the theme and the plugins broke something, but I didn’t know what. I looked into the Microhooks instructions, but as far as I could tell, everything was set up correctly. I have a test blog, and when I ran the same code on it, the issue with the archive page repeated, while the Emacs Org-mode page was fixed. I went back and forth a couple of times, but I couldn’t see anything that would cause the problem.
Over the weekend, I had more time, so I took a deeper look into the theme. I am far from a Hugo expert (in fact, I one of the main reasons I oppted for Micro.blog was to stop working with on my static blog directly) but I understand the general idea of how things are built: there’s one main page which calls other parts, and these parts call other parts in turn, each one is defined in a separate HTML file. I scanned the different HTML files of the theme and found where the Microhooks I used were activated.
For the archive and search page, there is layouts/_default/list.archivehtml.html, which includes the following lines:
{{ if templates.Exists "partials/microhook-archive-lead.html" }}
{{ partial "microhook-archive-lead.html" . }}
{{ end }
That partial (which is Hugo’s sort of “functions” or quick plug-ins for the theme), microhook-archive-lead.html, is the microhook HTML I created to include the search plugin and the intro to the archive and search page. This looked OK to me at the time, until I saw that another page, layouts/list.archivehtml.html, contained no reference to this Microhook. This looked odd to me: both pages have the same name (and thus the same function, I guessed). One is called default, and the default one is the one that was modified with my changes? That didn’t make sense.
This is where I fired up Qwen3-Coder (through Kagi) to help me understand how these pages work in Hugo. I asked it which page Hugo uses first, and sure enough, it replied that layouts/_default/list.archivehtml.html page is the default, sometimes used as a fallback option when layouts/list.archivehtml.html is not present1. So, as it turned out, my files were flipped: the default file showed the changes, while the file meant for customizations showed the default. I copied the code condition above from the layouts/_default/list.archivehtml.html to layouts/list.archivehtml.html, and things started to work as they should.
Why this happened, I have no idea. I made no changes to the pages. My only theory is that a recent update flipped the code in the files somehow for whatever reason.
My other issue was a stupid user error, as most of these issues go. The Microhook layouts/partials/microhook-category-header.html is the one responsible for pointing out which category page should have a special introduction. What the LLM told me that I didn’t know (or maybe forgot) is that it does that by utilizing the page’s .title variable. This is where I made a mistake: I used the file’s name, using the URL, not the title of the page, which happened to be different. Since this was a conditional statement looking for a specific page title that wasn’t found, it was ignored. Once I changed the value in the HTML to reflect that page’s proper title, it was fixed. Of course, it was a damn dash I omitted by mistake.
The fun of blogging
While this was a technical issue, it affected my desire to blog. As long as my pages didn’t work correctly and I couldn’t fix them, I didn’t want to blog. It didn’t feel right, even though these issues were not critical, at least from the readers' point of view, but they were important to me. I enjoy my blog. I had to fix it. Once I did, that feeling reversed completely, and my desire returned in force. The post you’re reading now was itching to be written, and it’s only now, half an hour before midnight, that I have the time and some reserve energy to draft it. It feels good.
Footnotes
1: I can’t emphasize how useful AI has been in scanning Hugo (or other technical documentation in general) and explaining things to me in plain English. I could spend hours looking at Hugo’s documentation and indexes, rereading the same sentences over and over, and not understand what something does or how it works with something else. Even now, as I write this post and check for links, the AI links me to the relevant section in the documentation, which I would otherwise just glaze over. It’s like having a teacher holding a pencil to a word or a phrase in a huge textbook.