Skip to main content

SiteParam

The siteparam shortcode prints values of site-wide params contained in your project configuration.

This text comes from your configuration

Usage

​
{{% siteparam name="siteparam.test.greetings" %}}
{{% siteparam "siteparam.test.greetings" %}}
{{ partial "shortcodes/siteparam.html" (dict
  "page" .
  "name" "siteparam.test.greetings"
)}}

To print params from a page’s front matter and falling back to the site options, use Hugo’s built-in param shortcode.

Parameters

Name Position Default Notes
name 1 <empty> The name of the site param to be displayed.

Examples

editURL

​
`editURL` value: {{% siteparam name="editURL" %}}
`editURL` value: {{% siteparam "editURL" %}}
`editURL` value: {{ partial "shortcodes/siteparam.html" (dict
  "page" .
  "name" "editURL"
)}}
editURL value: https://github.com/McShelby/hugo-theme-relearn/edit/main/docs/content/${FilePath}

Nested Parameter with Markdown and HTML Formatting

To use formatted parameter, add this in your project configuration:

hugo.
markup:
  goldmark:
    renderer:
      unsafe: true
[markup]
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true
{
   "markup": {
      "goldmark": {
         "renderer": {
            "unsafe": true
         }
      }
   }
}

Now values containing Markdown will be formatted correctly.

hugo.
params:
  siteparam:
    test:
      text: A **nested** parameter <b>with</b> formatting
[params]
  [params.siteparam]
    [params.siteparam.test]
      text = 'A **nested** parameter <b>with</b> formatting'
{
   "params": {
      "siteparam": {
         "test": {
            "text": "A **nested** parameter \u003cb\u003ewith\u003c/b\u003e formatting"
         }
      }
   }
}
​
Formatted parameter: {{% siteparam name="siteparam.test.text" %}}
Formatted parameter: {{% siteparam "siteparam.test.text" %}}
Formatted parameter: {{ partial "shortcodes/siteparam.html" (dict
  "page" .
  "name" "siteparam.test.text"
)}}
Formatted parameter: A nested option <b>with</b> formatting