hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

param.md (1440B)

    1 ---
    2 title: .Param
    3 description: Calls page or site variables into your template.
    4 date: 2017-02-01
    5 publishdate: 2017-02-01
    6 lastmod: 2017-04-30
    7 keywords: ["front matter"]
    8 categories: [functions]
    9 menu:
   10   docs:
   11     parent: "functions"
   12 toc:
   13 signature: [".Param KEY"]
   14 workson: []
   15 hugoversion:
   16 relatedfuncs: [default]
   17 deprecated: false
   18 draft: false
   19 aliases: []
   20 ---
   21 
   22 In Hugo, you can declare [site-wide params][sitevars] (i.e. in your [configuration][]), as well as params for [individual pages][pagevars].
   23 
   24 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).
   25 
   26 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:
   27 
   28 ```
   29 $.Param "image"
   30 ```
   31 
   32 {{% note %}}
   33 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](/functions/default/) instead of `Param`. See the [related issue on GitHub](https://github.com/gohugoio/hugo/issues/3366).
   34 {{% /note %}}
   35 
   36 
   37 [configuration]: /getting-started/configuration/
   38 [front matter]: /content-management/front-matter/
   39 [pagevars]: /variables/page/
   40 [sitevars]: /variables/site/