Params
- Syntax
- PAGE.Params
- Returns
- hmaps.Params
By way of example, consider this front matter:
---
date: 2023-10-17T15:11:37-07:00
params:
author:
email: jsmith@example.org
name: John Smith
display_related: true
key-with-hyphens: must use index function
title: Annual conference
---+++
date = 2023-10-17T15:11:37-07:00
title = 'Annual conference'
[params]
display_related = true
key-with-hyphens = 'must use index function'
[params.author]
email = 'jsmith@example.org'
name = 'John Smith'
+++{
"date": "2023-10-17T15:11:37-07:00",
"params": {
"author": {
"email": "jsmith@example.org",
"name": "John Smith"
},
"display_related": true,
"key-with-hyphens": "must use index function"
},
"title": "Annual conference"
}
The title and date fields are reserved front matter fields, while the fields under the params key are custom fields.
Use the Params method to access custom fields. To access a reserved field, call the corresponding method on a Page object, such as Title or Date. See the list of front matter fields for the method that corresponds to each reserved field.
Deprecated in v0.169.0
Accessing a reserved field with the Params method, such as .Params.title, is deprecated. Call the corresponding method instead, such as .Title. To access the summary field, call the RawSummary method. Hugo does not log a deprecation warning in every case.
Access the custom fields by chaining the identifiers when needed:
{{ .Params.display_related }} → true
{{ .Params.author.email }} → jsmith@example.org
{{ .Params.author.name }} → John SmithIn 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 .Params "key-with-hyphens" }} → must use index function