Hugo .Context
So in Hugo you use the .
to access variables and other information related to the page/site. .Title
or .Resources.GetMatch "image"
At first it seems simple, however once you go out of context it changes.
When it happed to me the error was very vague:execute of template failed: panic in Execute: reflect: Method on nil interface value. See "https://github.com/gohugoio/hugo/issues/5327" for the reason why we cannot provide a better error message for this."
Hugo documentation doesn’t talk about it when mentioning variables.
It does in the template introduction though, like they expect you to read it in order. π
The basics is that .
changes. You have a few ways to work with it, you can call the root .
by calling $.
, or you can store it in a variable $Page := .
.
RΓ©gis Philibert has a really good blog post you should read.