hugo/docs/content/en/methods/site/Params.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.3 KiB

title description categories keywords action
Params Returns a map of custom parameters as defined in the site configuration.
related returnType signatures
functions/collections/indexFunction
methods/page/Params
methods/page/Param
maps.Params
SITE.Params

With this site configuration:

{{< code-toggle file=hugo >}} [params] subtitle = 'The Best Widgets on Earth' copyright-year = '2023' [params.author] email = 'jsmith@example.org' name = 'John Smith' [params.layouts] rfc_1123 = 'Mon, 02 Jan 2006 15:04:05 MST' rfc_3339 = '2006-01-02T15:04:05-07:00' {{< /code-toggle >}}

Access the custom parameters by chaining the identifiers:

{{ .Site.Params.subtitle }} → The Best Widgets on Earth
{{ .Site.Params.author.name }} → John Smith

{{ $layout := .Site.Params.layouts.rfc_1123 }}
{{ .Site.LastChange.Format $layout }} → Tue, 17 Oct 2023 13:21:02 PDT

In the template example above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the index function:

{{ index .Site.Params "copyright-year" }} → 2023