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.
hugo.
services: null
{
"services": null
}
For example, to use Hugo’s built-in Google Analytics template you must add a [Google tag ID]:
hugo.
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:
hugo.
privacy: null
{
"privacy": null
}
For example, to disable usage of the built-in YouTube shortcode:
hugo.
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.