Back to Hugo

Config

docs/content/en/methods/site/Config.md

0.161.11.0 KB
Original Source

The Config method on a Site object provides access to a subset of your project 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:

{{< code-toggle file=hugo >}} [services.googleAnalytics] id = 'G-XXXXXXXXX' {{< /code-toggle >}}

To access this value from a template:

go-html-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:

{{< code-toggle file=hugo >}} [privacy.youtube] disable = true {{< /code-toggle >}}

To access this value from a template:

go-html-template
{{ .Site.Config.Privacy.YouTube.Disable }} → true

You must capitalize each identifier as shown above.