HUGO
News Docs Themes Community GitHub

Configure params

Create custom site parameters.

Use the params key for custom parameters:

baseURL: https://example.org/
languageCode: en-US
params:
  contact:
    email: info@example.org
    phone: +1 206-555-1212
  subtitle: Reference, Tutorials, and Explanations
title: Project Documentation
baseURL = 'https://example.org/'
languageCode = 'en-US'
title = 'Project Documentation'
[params]
  subtitle = 'Reference, Tutorials, and Explanations'
  [params.contact]
    email = 'info@example.org'
    phone = '+1 206-555-1212'
{
   "baseURL": "https://example.org/",
   "languageCode": "en-US",
   "params": {
      "contact": {
         "email": "info@example.org",
         "phone": "+1 206-555-1212"
      },
      "subtitle": "Reference, Tutorials, and Explanations"
   },
   "title": "Project Documentation"
}

Access the custom parameters from your templates using the Params method on a Site object:

{{ .Site.Params.subtitle }} → Reference, Tutorials, and Explanations
{{ .Site.Params.contact.email }} → info@example.org

Key names should use camelCase or snake_case. While TOML, YAML, and JSON allow kebab-case keys, they are not valid identifiers and cannot be used when chaining identifiers.

For example, you can do either of these:

{{ .Site.params.camelCase.foo }}
{{ .Site.params.snake_case.foo }}

But you cannot do this:

{{ .Site.params.kebab-case.foo }}

Multilingual sites

For multilingual sites, create a params key under each language:

baseURL: https://example.org/
defaultContentLanguage: en
languages:
  de:
    languageCode: de-DE
    languageDirection: ltr
    languageName: Deutsch
    params:
      contact:
        email: info@de.example.org
        phone: +49 30 1234567
      subtitle: Referenz, Tutorials und Erklärungen
    title: Projekt Dokumentation
    weight: 1
  en:
    languageCode: en-US
    languageDirection: ltr
    languageName: English
    params:
      contact:
        email: info@example.org
        phone: +1 206-555-1212
      subtitle: Reference, Tutorials, and Explanations
    title: Project Documentation
    weight: 2
baseURL = 'https://example.org/'
defaultContentLanguage = 'en'
[languages]
  [languages.de]
    languageCode = 'de-DE'
    languageDirection = 'ltr'
    languageName = 'Deutsch'
    title = 'Projekt Dokumentation'
    weight = 1
    [languages.de.params]
      subtitle = 'Referenz, Tutorials und Erklärungen'
      [languages.de.params.contact]
        email = 'info@de.example.org'
        phone = '+49 30 1234567'
  [languages.en]
    languageCode = 'en-US'
    languageDirection = 'ltr'
    languageName = 'English'
    title = 'Project Documentation'
    weight = 2
    [languages.en.params]
      subtitle = 'Reference, Tutorials, and Explanations'
      [languages.en.params.contact]
        email = 'info@example.org'
        phone = '+1 206-555-1212'
{
   "baseURL": "https://example.org/",
   "defaultContentLanguage": "en",
   "languages": {
      "de": {
         "languageCode": "de-DE",
         "languageDirection": "ltr",
         "languageName": "Deutsch",
         "params": {
            "contact": {
               "email": "info@de.example.org",
               "phone": "+49 30 1234567"
            },
            "subtitle": "Referenz, Tutorials und Erklärungen"
         },
         "title": "Projekt Dokumentation",
         "weight": 1
      },
      "en": {
         "languageCode": "en-US",
         "languageDirection": "ltr",
         "languageName": "English",
         "params": {
            "contact": {
               "email": "info@example.org",
               "phone": "+1 206-555-1212"
            },
            "subtitle": "Reference, Tutorials, and Explanations"
         },
         "title": "Project Documentation",
         "weight": 2
      }
   }
}

Namespacing

To prevent naming conflicts, module and theme developers should namespace any custom parameters specific to their module or theme.

params:
  modules:
    myModule:
      colors:
        background: '#efefef'
        font: '#222222'
[params]
  [params.modules]
    [params.modules.myModule]
      [params.modules.myModule.colors]
        background = '#efefef'
        font = '#222222'
{
   "params": {
      "modules": {
         "myModule": {
            "colors": {
               "background": "#efefef",
               "font": "#222222"
            }
         }
      }
   }
}

To access the module/theme settings:

{{ $cfg := .Site.Params.module.mymodule }}

{{ $cfg.colors.background }} → #efefef
{{ $cfg.colors.font }} → #222222