HUGO
News Docs Themes Community GitHub

Config

Returns a subset of the site configuration.

Syntax

SITE.Config

Returns

page.SiteConfig

The Config method on a Site object provides access to a subset of the site configuration, specifically the services and privacy keys.

Services

These are the default service settings, typically used by Hugo’s built-in templates and shortcodes.

services:
  disqus:
    shortname: ""
  googleAnalytics:
    id: ""
  instagram:
    accessToken: ""
    disableInlineCSS: false
  rss:
    limit: -1
  twitter:
    disableInlineCSS: false
  x:
    disableInlineCSS: false
[services]
  [services.disqus]
    shortname = ''
  [services.googleAnalytics]
    id = ''
  [services.instagram]
    accessToken = ''
    disableInlineCSS = false
  [services.rss]
    limit = -1
  [services.twitter]
    disableInlineCSS = false
  [services.x]
    disableInlineCSS = false
{
   "services": {
      "disqus": {
         "shortname": ""
      },
      "googleAnalytics": {
         "id": ""
      },
      "instagram": {
         "accessToken": "",
         "disableInlineCSS": false
      },
      "rss": {
         "limit": -1
      },
      "twitter": {
         "disableInlineCSS": false
      },
      "x": {
         "disableInlineCSS": false
      }
   }
}

For example, to use Hugo’s built-in Google Analytics template you must add a Google tag ID:

services:
  googleAnalytics:
    id: G-XXXXXXXXX
[services]
  [services.googleAnalytics]
    id = 'G-XXXXXXXXX'
{
   "services": {
      "googleAnalytics": {
         "id": "G-XXXXXXXXX"
      }
   }
}

To access this value from a template:

{{ .Site.Config.Services.GoogleAnalytics.ID }} → G-XXXXXXXXX

You must capitalize each identifier as shown above.

Privacy

These are the default privacy settings, typically used by Hugo’s built-in templates and shortcodes:

privacy:
  disqus:
    disable: false
  googleAnalytics:
    disable: false
    respectDoNotTrack: false
  instagram:
    disable: false
    simple: false
  twitter:
    disable: false
    enableDNT: false
    simple: false
  vimeo:
    disable: false
    enableDNT: false
    simple: false
  x:
    disable: false
    enableDNT: false
    simple: false
  youTube:
    disable: false
    privacyEnhanced: false
[privacy]
  [privacy.disqus]
    disable = false
  [privacy.googleAnalytics]
    disable = false
    respectDoNotTrack = false
  [privacy.instagram]
    disable = false
    simple = false
  [privacy.twitter]
    disable = false
    enableDNT = false
    simple = false
  [privacy.vimeo]
    disable = false
    enableDNT = false
    simple = false
  [privacy.x]
    disable = false
    enableDNT = false
    simple = false
  [privacy.youTube]
    disable = false
    privacyEnhanced = false
{
   "privacy": {
      "disqus": {
         "disable": false
      },
      "googleAnalytics": {
         "disable": false,
         "respectDoNotTrack": false
      },
      "instagram": {
         "disable": false,
         "simple": false
      },
      "twitter": {
         "disable": false,
         "enableDNT": false,
         "simple": false
      },
      "vimeo": {
         "disable": false,
         "enableDNT": false,
         "simple": false
      },
      "x": {
         "disable": false,
         "enableDNT": false,
         "simple": false
      },
      "youTube": {
         "disable": false,
         "privacyEnhanced": false
      }
   }
}

For example, to disable usage of the built-in YouTube shortcode:

privacy:
  youtube:
    disable: true
[privacy]
  [privacy.youtube]
    disable = true
{
   "privacy": {
      "youtube": {
         "disable": true
      }
   }
}

To access this value from a template:

{{ .Site.Config.Privacy.YouTube.Disable }} → true

You must capitalize each identifier as shown above.