main matter
This article assumes you know the basics about the Hugo static site generator.
Abstractly a Hugo page’s primary[2] source file looks like this:
front matter |
---|
main matter |
Details about this are in Infinite Ink’s Hugo Tutorial in the section Anatomy of a content file.
In a Hugo layout file, the main matter of a page can be accessed with the following page variables.
.RawContent
The main matter as it appears in the source file, i.e., everything below the front matter.
.Content
The main matter after it has been processed by Hugo with the help of a markup renderer, such as Asciidoctor, go-org, Goldmark, or Pandoc.
One way to check if a page has changed is to check its fingerprint or hash. For example, a hash of this page’s RawContent is:
3BC625
The Hugo shortcode that produces the above hash includes one of the following lines.
{{ .Page.RawContent | sha256 | truncate 6 "" | upper }} {{ substr (.Page.RawContent | sha256 | upper) 0 6 }} {{ slicestr (.Page.RawContent | sha256 | upper) 0 6 }}
Each of the above three lines produces this:
3BC625
If
a page does
not use any
external snippets,[3]
it’s
often
sufficient to
use the above
.Page.RawContent
fingerprint.
But if a page uses
external snippets,
you need to fingerprint
.Page.Content
with, for example, this:
{{ .Page.Content | sha256 | truncate 6 "" | upper }}
Fingerprinting the Content, rather than the RawContent, is needed because it’s possible that the RawContent is unchanged but one (or more) external snippet has changed.
A hash of the Content of this page is in the Page Meta section below.
For more about Hugo, see Infinite Ink’s…
Configuring Security in Hugo (featuring settings needed to use Asciidoctor and Pandoc)
🔗 Linkified Section Headings in Hugo-Generated Web Pages (featuring Markdown and AsciiDoc examples)
Hugo’s Markup Languages: AsciiDoc, HTML, Markdown,
Variable and Parameter Names in Hugo (featuring camelCase🐫 and snake_case🐍)
A Way to Compare Hugo’s Markup Languages (featuring inline footnotes)
Hugo Tutorial: Themeless & Gitless Introduction to the Hugo SSG
Your public comment or question might immediately improve this page or help me to (eventually) improve this page.