This post contains nothing but notes that I took while experimenting Hugo templates. To understand each page and it’s variables (properties) I’ve created a partial called hugo_debug.html
and used it in baseof.html
, simply by adding this line: {{ partial "hugo_debug.html" . }}
<div>
Title: {{.Title}} <br>
Kind: {{.Kind}} <br>
Section: {{.Section}} <br>
Type: {{.Type}} <br>
Layout: {{.Layout}}<br>
Site Author: {{.Site.Author.FullName}}<br>
Author: {{ .Params.Author }} <br>
Categories: {{ .Params.Categories }} <br>
Date: {{.Date.Format "2006-01-02 Monday"}}<br>
Params: {{.Params}}<br>
</div>
Section vs Type
- Section is the first folder under content (content/blog => blog)
- Section cannot be set in front matter
- Type can be set in front matter
- If Type isn’t set, the value of Section will be used
Example: for a file named “foo” from a section called “posts”.
/content/post/foo.md
Type: post
Section: post
Kind: page
Example: for a file named “bar” from a section called “foo”.
/content/foo/bar.md
Type: foo
Section: foo
Kind: page
Section Pages
Section pages are the index pages or home pages for that section. These pages are created auto-magically by Hugo and we can overwrite them by simply creating a file called _index.md
in that section.
/content/foo/
Type: foo
Section: foo
Kind: section
Ordinary Pages (about.md)
/content/about.md
Normally, these pages have the following properties. Yet, I set Type: ordinary
to be able to separate them from normal blog posts while listing content with Hugo templates. Explained here
Type: page
Section:
Kind: page
Taxonomy
Hugo lets us group content with taxonomies.
/categories
Type: categories
Section: categories
Kind: taxonomy
Term
/categories/foo
Type: categories
Section: categories
Kind: term