| 1 |
--- |
| 2 |
title: Params |
| 3 |
description: Returns a map of custom parameters as defined in the front matter of the given page. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: maps.Params |
| 9 |
signatures: [PAGE.Params] |
| 10 |
--- |
| 11 |
|
| 12 |
By way of example, consider this front matter: |
| 13 |
|
| 14 |
{{< code-toggle file=content/annual-conference.md fm=true >}} |
| 15 |
title = 'Annual conference' |
| 16 |
date = 2023-10-17T15:11:37-07:00 |
| 17 |
[params] |
| 18 |
display_related = true |
| 19 |
key-with-hyphens = 'must use index function' |
| 20 |
[params.author] |
| 21 |
email = '[email protected]' |
| 22 |
name = 'John Smith' |
| 23 |
{{< /code-toggle >}} |
| 24 |
|
| 25 |
The `title` and `date` fields are standard [front matter fields][], while the other fields are user-defined. |
| 26 |
|
| 27 |
Access the custom fields by [chaining](g) the [identifiers](g) when needed: |
| 28 |
|
| 29 |
```go-html-template |
| 30 |
{{ .Params.display_related }} → true |
| 31 |
{{ .Params.author.email }} → [email protected] |
| 32 |
{{ .Params.author.name }} → John Smith |
| 33 |
``` |
| 34 |
|
| 35 |
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: |
| 36 |
|
| 37 |
```go-html-template |
| 38 |
{{ index .Params "key-with-hyphens" }} → must use index function |
| 39 |
``` |
| 40 |
|
| 41 |
[`index`]: /functions/collections/indexfunction/ |
| 42 |
[front matter fields]: /content-management/front-matter/#fields |