From b5e4b0fef8c7bfb768a9e9e0d47e8b136f9cbc1d Mon Sep 17 00:00:00 2001
From: Felix Boerner <ich@felix-boerner.de>
Date: Fri, 31 May 2024 19:19:20 +0000
Subject: [PATCH] feat: replace deprecated .Site.GoogleAnalytics
---
layouts/partials/head.html | 4 ++--
tests/exampleSiteWithVideo/hugo.toml | 8 +++++---
tests/exampleSiteWithImage/hugo.toml | 8 +++++---
README.md | 6 ++++--
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index edc389a..c8dfff7 100644
--- a/README.md
+++ b/README.md
@@ -188,10 +188,12 @@
### Add Google Analytics
-Enable Google Analytics by adding your tracking id to `googleAnalytics`. Leave empty or remove if you don't want.
+Enable Google Analytics by adding your tracking id to `services.googleAnalytics`. Leave empty or remove if you don't want.
```toml
-googleAnalytics = "UA-XXXXXXXX-1"
+[services]
+ [services.googleAnalytics]
+ ID = "UA-XXXXXXXX-1"
```
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index d2e1721..9ef53f9 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -34,10 +34,10 @@
<!-- Custom Styles -->
{{ if .Site.Params.custom.css.enable }}
-<link rel="stylesheet" href="{{ "css/style.css" | absURL }}" type="text/css" media="screen" />
+ <link rel="stylesheet" href="{{ "css/style.css" | absURL }}" type="text/css" media="screen" />
{{ end }}
<!-- Google Analytics -->
-{{ if and (.Site.GoogleAnalytics) (not (in (printf "%#v" .Site.BaseURL) "localhost")) }}
+{{ if and (.Site.Config.Services.GoogleAnalytics.ID) (not (in (printf "%#v" .Site.BaseURL) "localhost")) }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
diff --git a/tests/exampleSiteWithImage/hugo.toml b/tests/exampleSiteWithImage/hugo.toml
index b626921..de522ab 100644
--- a/tests/exampleSiteWithImage/hugo.toml
+++ b/tests/exampleSiteWithImage/hugo.toml
@@ -10,12 +10,14 @@
relativeURLs = true
uglyURLs = true
-# Enter your tracking code to enable Google Analytics
-googleAnalytics = ""
-
# Copyright
copyright = "©2024 Your Name"
+[services]
+ [services.googleAnalytics]
+ # Enter your tracking code to enable Google Analytics
+ ID = ""
+
[params]
# Metadata for search engines and social sharing
diff --git a/tests/exampleSiteWithVideo/hugo.toml b/tests/exampleSiteWithVideo/hugo.toml
index 33efa81..0c8d8cb 100644
--- a/tests/exampleSiteWithVideo/hugo.toml
+++ b/tests/exampleSiteWithVideo/hugo.toml
@@ -10,12 +10,14 @@
relativeURLs = true
uglyURLs = true
-# Enter your tracking code to enable Google Analytics
-googleAnalytics = ""
-
# Copyright
copyright = "©2024 Your Name"
+[services]
+ [services.googleAnalytics]
+ # Enter your tracking code to enable Google Analytics
+ ID = ""
+
[params]
# Metadata for search engines and social sharing
--
Gitblit v1.10.0