mirror of https://github.com/escalate/hugo-split-theme.git

Felix Boerner
31.19.2024 b5e4b0fef8c7bfb768a9e9e0d47e8b136f9cbc1d
feat: replace deprecated .Site.GoogleAnalytics
4 files modified
26 ■■■■■ changed files
README.md 6 ●●●●● patch | view | raw | blame | history
layouts/partials/head.html 4 ●●●● patch | view | raw | blame | history
tests/exampleSiteWithImage/hugo.toml 8 ●●●●● patch | view | raw | blame | history
tests/exampleSiteWithVideo/hugo.toml 8 ●●●●● patch | view | raw | blame | history
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"
```
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 }}
tests/exampleSiteWithImage/hugo.toml
@@ -10,12 +10,14 @@
relativeURLs = true
uglyURLs = true
# Enter your tracking code to enable Google Analytics
googleAnalytics = ""
# Copyright
copyright = "&copy;2024 Your Name"
[services]
  [services.googleAnalytics]
    # Enter your tracking code to enable Google Analytics
    ID = ""
[params]
  # Metadata for search engines and social sharing
tests/exampleSiteWithVideo/hugo.toml
@@ -10,12 +10,14 @@
relativeURLs = true
uglyURLs = true
# Enter your tracking code to enable Google Analytics
googleAnalytics = ""
# Copyright
copyright = "&copy;2024 Your Name"
[services]
  [services.googleAnalytics]
    # Enter your tracking code to enable Google Analytics
    ID = ""
[params]
  # Metadata for search engines and social sharing