Skip to content

Commit 1dc5c66

Browse files
committed
fix(analytic): Define .Site.Config.Services.GoogleAnalytics.ID
.Site.GoogleAnalytics was deprecated in v0.120.0 Signed-off-by: Khusika Dhamar Gusti <[email protected]>
1 parent ff29096 commit 1dc5c66

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

exampleSite/hugo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,11 @@ ignoreErrors = ["err-missing-comment-accesstoken", "err-missing-oembed-accesstok
11251125
# posts = ":year/:month/:filename"
11261126
posts = ":filename"
11271127

1128+
[services.googleAnalytics]
1129+
# UA-PROPERTY_ID or G-MEASUREMENT_ID google analytics code
1130+
# UA-PROPERTY_ID 或者是 G-MEASUREMENT_ID 的 google analytics 代码
1131+
ID = ""
1132+
11281133
# Privacy config (https://gohugo.io/about/hugo-and-gdpr/)
11291134
# 隐私信息配置 (https://gohugo.io/about/hugo-and-gdpr/)
11301135
[privacy]

layouts/_default/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{{- partial "head/seo.html" . -}}
2020

2121
{{- $analytics := .Site.Config.Privacy.GoogleAnalytics -}}
22-
{{- if and (not $analytics.Disable) (.Site.GoogleAnalytics) -}}
22+
{{- if and (not $analytics.Disable) (.Site.Config.Services.GoogleAnalytics.ID) -}}
2323
{{- template "_internal/google_analytics.html" . -}}
2424
{{- end -}}
2525
</head>

layouts/partials/head/link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
{{- if ne $offline true -}}
8383
{{- $analytics := .Site.Config.Privacy.GoogleAnalytics -}}
84-
{{- if not $analytics.Disable }}{{ with .Site.GoogleAnalytics -}}
84+
{{- if not $analytics.Disable }}{{ with .Site.Config.Services.GoogleAnalytics.ID -}}
8585
{{ if hasPrefix . "G-"}}
8686
<link href="https://www.googletagmanager.com" rel="preconnect" crossorigin>
8787
<link rel="dns-prefetch" href="https://www.googletagmanager.com">

0 commit comments

Comments
 (0)