File: Config.md

package info (click to toggle)
hugo 0.131.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 45,580 kB
  • sloc: javascript: 31,172; xml: 248; makefile: 73; sh: 42
file content (57 lines) | stat: -rw-r--r-- 1,413 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: Config
description: Returns a subset of the site configuration.
categories: []
keywords: []
action:
  related: []
  returnType: page.SiteConfig
  signatures: [SITE.Config]
toc: true
---

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.

{{< code-toggle config=services />}}

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

[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en

{{< 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

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

{{< code-toggle config=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.