Hugo Content Layout

Today I worked on another static site and learned more about Hugo’s content management organization.

Specifically, I learned much more about the distinction between sections, types, and taxonomies. These concepts are all related, and can all produce aggregate lists, but have very different degrees and mechanisms to configure.

sections are opinionated, unchangeable, attributes that are determined by where a file is placed. Seemingly the documentation indicates they are the top level directories under content, however there does appear to be some support for nested sections, including an open issue related to their documentation.

types are inferred from sections, but can also be specified in the frontmatter of a document. Types seem to be primarily intended to change the default metadata and visual presentation. They can also be used to filter a paginator in order to create a list page.

Finally, taxonomies allow relations between pieces of content. I did not realize that the support for tags was through taxonomies (as is categories be default).

All together that is a lot of ways to slice and dice and present your content, which can be pretty powerful. Also I have to give hugo lots of credit for making sane defaults and inferring things whenever possible without making it seem like too much magic. Additionally, the documentation is really good.

I did run into some interesting behavior related to _index.md pages, and how sections where inferred in nested directories, but did not keep enough notes to fully debug (also wasn’t sure the expected behavior prior to learning all this). Essentially a post in a nested sub folder under a top level section would be included in that section, but would not show up in the default paginator if an _index.md file was in it’s sub directory. Otherwise it would. I’ll leave you with that mystery (my hack resolution was to change the paginator to be based on type, I’ll have to think more on that).

meta

I even passed up on my analog beeminder goal to make this post and hit a week long streak! Also I made all my goals public today!