Content Archives in Hugo

12/12/19

Tags Grand Unified Archive

Finally got around to adding posts I found from 2016 and 2017. I decided to create a Grand Unified Archive that will include all microblogs, blogs, and pages added in any given year on a single page. Archives are not baked in to Hugo, but can be created by adding a taxonomy to config.toml per onedrawingperday’s example. (Be advised I use uglyurls, which must be enabled in config.)

[taxonomies]
  year = "year"

[permalinks] year = "/archive/:slug/"

Every item on the site has a “year” frontmatter and /archive/(year).html now lists all those items. Easy, except… Hugo still generates a “year.html” in the home directory with incorrect links (e.g. /year/2016.html). We want it to generate in /archive/ and we want it to be an index.html file.

/content/year/_index.md
---
url: "/archive/index.html"
title: Archive
---

Resolves the problem with the index file, but not the urls, which still contain “year”. We need to add custom templates and manually update the url in the term layout.

layouts/year/terms.html <- index.html layouts/year/list.html <- individual year archive lists

This is a little different than what I originally planned and I’m not sure if I’ll keep it. But now I’ve come back around to the idea of adding pagination to the microblog to provide a more natural way to read through it that doesn’t create text redundancies by having summaries on list pages. Why is it, every time I “fix” something on the site, I come up with 5 more things to add? Honestly. At least adding pagination was trivial.