I did some cleanup of the categories and tag listings. This short post discusses why and how!
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
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.
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.