| 1 |
--- |
| 2 |
title: Config |
| 3 |
description: Returns a subset of your project configuration. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: page.SiteConfig |
| 9 |
signatures: [SITE.Config] |
| 10 |
--- |
| 11 |
|
| 12 |
The `Config` method on a `Site` object provides access to a subset of your project configuration, specifically the `services` and `privacy` keys. |
| 13 |
|
| 14 |
## Services |
| 15 |
|
| 16 |
See [configure services](/configuration/services). |
| 17 |
|
| 18 |
For example, to use Hugo's built-in Google Analytics template you must add a [Google tag ID]: |
| 19 |
|
| 20 |
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en |
| 21 |
|
| 22 |
{{< code-toggle file=hugo >}} |
| 23 |
[services.googleAnalytics] |
| 24 |
id = 'G-XXXXXXXXX' |
| 25 |
{{< /code-toggle >}} |
| 26 |
|
| 27 |
To access this value from a template: |
| 28 |
|
| 29 |
```go-html-template |
| 30 |
{{ .Site.Config.Services.GoogleAnalytics.ID }} → G-XXXXXXXXX |
| 31 |
``` |
| 32 |
|
| 33 |
You must capitalize each identifier as shown above. |
| 34 |
|
| 35 |
## Privacy |
| 36 |
|
| 37 |
See [configure privacy](/configuration/privacy). |
| 38 |
|
| 39 |
For example, to disable usage of the built-in YouTube shortcode: |
| 40 |
|
| 41 |
{{< code-toggle file=hugo >}} |
| 42 |
[privacy.youtube] |
| 43 |
disable = true |
| 44 |
{{< /code-toggle >}} |
| 45 |
|
| 46 |
To access this value from a template: |
| 47 |
|
| 48 |
```go-html-template |
| 49 |
{{ .Site.Config.Privacy.YouTube.Disable }} → true |
| 50 |
``` |
| 51 |
|
| 52 |
You must capitalize each identifier as shown above. |