main matter
Â
2023-August-17Â
As of today, this evolvingâ [1]
article
has been on
the web
for
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 markup renderers, 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:
2331E9
The Hugo shortcode that produced 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:
2331E9
Â
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 an external snippet has changed.
A hash of the Content of this page is in the Page Meta section below.
gohugo.io/variables/page/ (discusses .Content
, .RawContent
, etc.)
Â
For more about Hugo, see Infinite InkâsâŠ
Hugoâs .RenderString
Method (featuring AsciiDoc admonitions in Markdown)
Hugoâs Markup Languages: AsciiDoc, HTML, Markdown,
Configuring Security in Hugo (featuring settings needed to use Asciidoctor and Pandoc)â đ
âEdit This Pageâ With vscode://
 URIs (featuring a Hugo partial)
TGIH: Themeless & Gitless Introduction to the Hugo SSG (a Hugo tutorialâ đ©âđ«)
Create a âShare on Mastodonâ link with Hugo and Tootpickâ đ
Using a renderas
Shortcode to Compare Hugoâs Markup Languages (featuring inline footnotes)â đ
Processing Images with Hugo (featuring flipping
Variable and Parameter Names in Hugo (featuring camelCaseâ đ« and snake_caseâ đ)
Hugo Shortcodes: How to Use Go Templates in Hugo Content Files
Transforming Text with Hugo (featuring plainify
, htmlUnescape
, and more)
Calling a Hugo Partial from a Hugo Shortcode (featuring âShare on Mastodonâ code)
Â
@nm@mathstodon.xyz
or
#InfiniteInk
in it.