I’m trying to loop on a map of keys and display the corresponding Page Variable. For this, I need to use a template variable ($whatever) to grab the Page Variable value. I know I cannot use index for that, but .Param or .Params are not helping either…)
This is an overly simplified illustrative example:
{{ $title := "Title" }}
{{ $permalink := "Permalink" }}
{{ .Param $title }} > works
{{ .Param $permalink }} > does not work
{{ index .Params $title }} > works
{{ index .Params $permalink }} > does not work
Only Title works.
Of course both methods work with Custom Page Params.
Is .Param supposed to work with Page Variable (Doc says: Calls page or site variables into your template)
Of course .Permalink works… though directly in the Page context… can you tell the type of the dot context there?
If the context is the Page, directly doing .Permalink works… but that of course does not solve your intention to make that a variable.
As for .Param, unless I am mistaken, it only works for front-matter-set parameters and the parameters set in [Params] in your site’s config.toml/yaml/…
Further in the documentation, this line makes it a bit clearer:
You can use the .Param method to call these values into your template. The following will first look for an image param in a specific content’s front matter. If not found, Hugo will look for an image param in your site’s configuration:
@bep Would the “description” of that .Param help page like this be more accurate?
Calls variables set in page front-matter or site params into your template.