Each piece of content in Hugo should have front matter. Front matter is like post meta. It can be formatted 4 ways: JSON, YAML, TOML, or ORG.
yaml format
---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
categories = ["Hugo","Front Matter","Templating"]
---
You might want to loop through all the strings in a given post's categories array. How is this done?
The Hugo range
function is an iterator function, useful for templating.
Each category in the Categories array can be referred to with the $category
variable.
{{ range $category := .Params.Categories }}
<p>
{{ $category }}
</p>
{{ end }}
The .Params
variable refers to the page-level parameters.
Page-level .Params [such as tags and categories] are only accessible in lowercase.