hugo/docs/content/en/functions/param.md

1.4 KiB

title description godocref date publishdate lastmod keywords categories menu toc signature workson hugoversion relatedfuncs deprecated draft aliases
.Param Calls page or site variables into your template. 2017-02-01 2017-02-01 2017-04-30
front matter
functions
docs
parent
functions
.Param KEY
default
false false

In Hugo, you can declare site-wide params (i.e. in your configuration), as well as params for individual pages.

A common use case is to have a general value for the site and a more specific value for some of the pages (e.g., an image).

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:

$.Param "image"

{{% note %}} The Param method may not consider empty strings in a content's front matter as "not found." If you are setting preconfigured front matter fields to empty strings using Hugo's archetypes, it may be best to use the default function instead of Param. See the related issue on GitHub. {{% /note %}}