Compare commits

...

2 Commits

Author SHA1 Message Date
Xin
2863a3a029
fix: remove deprecated site.GoogleAnalytics (#438)
Some checks are pending
Deploy Hugo site to Pages / build (push) Waiting to run
Deploy Hugo site to Pages / deploy (push) Blocked by required conditions
* fix: remove deprecated site.GoogleAnalytics

* ci: bump netlify Hugo version
2024-08-18 14:41:40 +01:00
Erik Skopp
852a07b15e
fix: remove deprecated google analytics reference in head.html (#435)
ERROR deprecated: .Site.GoogleAnalytics was deprecated in Hugo v0.120.0 and will be removed in Hugo 0.133.0. Use .Site.Config.Services.GoogleAnalytics.ID instead.
2024-08-18 12:31:50 +01:00
3 changed files with 7 additions and 14 deletions

View File

@ -1,10 +1,4 @@
{{/* site.GoogleAnalytics is deprecated in Hugo v0.120.0 */}}
{{/* it will be removed in a future version */}}
{{- $gtagID := "" -}}
{{- with site.GoogleAnalytics -}}{{ $gtagID = . }}{{- end -}}
{{- with site.Config.Services.GoogleAnalytics.ID -}}{{ $gtagID = . }}{{- end -}}
{{- with $gtagID }}
{{- with site.Config.Services.GoogleAnalytics.ID }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>

View File

@ -30,12 +30,11 @@
{{ partialCached "head-css.html" . }}
<!-- Google Analytics -->
{{- if and (eq hugo.Environment "production") (or .Site.GoogleAnalytics .Site.Config.Services.GoogleAnalytics.ID) }}
<link rel="preconnect" href="https://www.googletagmanager.com" crossorigin />
{{ partial "google-analytics.html" . }}
{{- end }}
<!-- Google Analytics -->
{{- if and (eq hugo.Environment "production") .Site.Config.Services.GoogleAnalytics.ID }}
<link rel="preconnect" href="https://www.googletagmanager.com" crossorigin />
{{ partial "google-analytics.html" . }}
{{- end }}
<script>
/* Initialize light/dark mode */

View File

@ -7,6 +7,6 @@ command = "cd exampleSite && hugo --gc --minify --themesDir ../.. -b ${DEPLOY_PR
ignore = "false"
[build.environment]
HUGO_VERSION = "0.126.1"
HUGO_VERSION = "0.132.2"
GO_VERSION = "1.22.3"
NODE_VERSION = "22.2.0"