I did some cleanup of the categories and tag listings. This short post discusses why and how!

Adding year-separation on category pages

What changed? On category pages, like books or what-i-read, I added smaller year headers to break up the otherwise-long lists. I did the same on tag pages, like site.

Why? I was writing some year in review posts, and I wanted to see which posts were from 2020 quickly! I could search on the page just fine, but a visual indicator was clearer. The same code exists on the archives page, so I figured it shouldn’t be too hard.

How? I modified my category.terms.html template. Basically, for each post in a category, I get the year of the current post. If it’s the first item (the current year) or different from the previous item (an older year), then I display a little year h4.

Displaying tags next to post previews

What changed? Also on category pages, like books or papers, I have little tag icons with the tags for each post listed.

Why? I wanted the tags to be visible in more places than just individual post pages. But I’m still not sure if I like this! It adds a lot of visual noise that I might remove.

How? I modified the item-post.html template. I used the same code as for listing paper authors, where if there are any tags I display them all. The code for this was a little bit awful; I took it from this StackOverflow answer.

Closing thoughts

I’m a little more disillusioned with Hugo templates (well, Go templates) than I was before. They’re powerful and feature-rich, and that’s not always a good thing. Figuring out how to make all of these poorly documented shortcodes interact was not fun; I was lucky that I had examples of what I wanted to do readily available.

I’m thinking a lot about the Why I built my own shitty static site generator article that I read a couple weeks ago. But I’ve done that, too, and I much prefer Hugo. Tradeoffs!