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
See configure services.
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
See configure privacy.
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.
Last updated:
March 5, 2025
:
content: Consolidate configuration documentation (b6cae5cbc)
Improve this page