Poop Sheet

Frontmatter

Each content file, ie an index.md for a leaf or _index.md for a branch, has what Hugo calls front matter, ie metadata that splits these files into a head and body section.

The default skeleton archetypes/default.md is

+++
date = '{{ .Date }}'
draft = true
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
+++

While the skeleton uses toml, it can be yaml or json, which I find simplest.

{
  "date":  "{{ .Date }}",
  "draft": true,
  "title": "{{ replace .File.ContentBaseName "-" " " | title }}"
}

Setting draft to true by default tripped me up, and I’m sure most other novices since that means your page doesn’t get rendered by default.

Another thing to be careful of is that “date” is not set to the future, because then it will also not get rendered by default.

Also confusing to novices is the difference between configuration fields, which go in hugo.json, and frontmatter. Configuration affects the entire site, whereas as frontmatter is page specific.

The documentation at time of writing has five categories of frontmatter fields.

Determines template selection

layout

I use {..., "layout": "event", ...} to then use layouts/event.html as the template.

Provide a template name to target a specific template, overriding the default template lookup order. Set the value to the base file name of the template, excluding its extension.

Establishes relationships with other content

keywords

Keywords for taxonomies are defined in the configuration hugo.json:

  "taxonomies": {
    "venue": "venues",
    "artist": "artists"
  },

This creates what looks to visitors like sections venues and artists, but are in Hugo jargon taxonomies.

The frontmatter of content pages then includes arays of terms to associate the page with.

{
  "artists": [
    "Velvet Alibi"
  ],
  "venues": [
    "Oasi Cestia"
  ]
}