Debian Codegraph @

docs/content/en/methods/site/Params.md

raw
1 ---
2 title: Params
3 description: Returns a map of custom parameters as defined in your project configuration.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: maps.Params
9 signatures: [SITE.Params]
10 ---
11
12 With this project configuration:
13
14 {{< code-toggle file=hugo >}}
15 [params]
16 subtitle = 'The Best Widgets on Earth'
17 copyright-year = '2023'
18 [params.author]
19 email = '[email protected]'
20 name = 'John Smith'
21 [params.layouts]
22 rfc_1123 = 'Mon, 02 Jan 2006 15:04:05 MST'
23 rfc_3339 = '2006-01-02T15:04:05-07:00'
24 {{< /code-toggle >}}
25
26 Access the custom parameters by [chaining](g) the [identifiers](g):
27
28 ```go-html-template
29 {{ .Site.Params.subtitle }} → The Best Widgets on Earth
30 {{ .Site.Params.author.name }} → John Smith
31
32 {{ $layout := .Site.Params.layouts.rfc_1123 }}
33 {{ .Site.Lastmod.Format $layout }} → Tue, 17 Oct 2023 13:21:02 PDT
34 ```
35
36 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:
37
38 ```go-html-template
39 {{ index .Site.Params "copyright-year" }} → 2023
40 ```
41
42 [`index`]: /functions/collections/indexfunction/