Skip to content

Commit

Permalink
Fix deprecated Google Analytics and Disqus settings (#85)
Browse files Browse the repository at this point in the history
* replace-google-analytics-setting

Fix: Replace deprecated .Site.GoogleAnalytics with .Site.Config.Services.GoogleAnalytics.ID

- Updated the Hugo configuration to use the new Google Analytics setting
  as the previous .Site.GoogleAnalytics is deprecated and will be removed in future versions.

* fix service param at README.md

fix README.md

* Update README.md

Analyticsに入っているべきサンプルIDがdisqusに入っているのを修正
  • Loading branch information
hamuchan214 authored Oct 21, 2024
1 parent c5e65bf commit fcf525f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ baseurl = "https://example.com/"
title = "SiteTitle"
theme = "hugo_theme_robust"
googleAnalytics = "UA-XXXXXXXX-XX" # Optional
disqusShortname = "XYW"
[services]
[services.disqus]
shortname = ''
[services.googleAnalytics]
id = 'UA-XXXXXXXX-XX' # Optical
[params]
description = "This is site description"
Expand Down
8 changes: 4 additions & 4 deletions layouts/_default/baseof.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{ partial "meta.html" . }}
{{ block "meta" . }}{{ end }}

{{ if and .Site.GoogleAnalytics (ne (getenv "HUGO_ENV") "DEV") }}
{{ if and .Site.Config.Services.GoogleAnalytics.ID (ne (getenv "HUGO_ENV") "DEV") }}
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<meta name="amp-google-client-id-api" content="googleanalytics">
{{ end }}
Expand Down Expand Up @@ -45,14 +45,14 @@
</head>

<body>
{{ if and .Site.GoogleAnalytics (ne (getenv "HUGO_ENV") "DEV") }}
{{ if and .Site.Config.Services.GoogleAnalytics.ID (ne (getenv "HUGO_ENV") "DEV") }}
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars" : {
"gtag_id": "{{ .Site.GoogleAnalytics }}}",
"gtag_id": "{{ .Site.Config.Services.GoogleAnalytics.ID }}}",
"config" : {
"{{ .Site.GoogleAnalytics }}}": { "groups": "default" }
"{{ .Site.Config.Services.GoogleAnalytics.ID }}}": { "groups": "default" }
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
{{ with .Site.Params.logofontfamily }} .h-logo { font-family: {{ . | safeCSS }}; } {{ end }}
{{ partial "custom.css" . | safeCSS }}
</style>
{{ if and .Site.GoogleAnalytics (ne (getenv "HUGO_ENV") "DEV") }}
{{ if and .Site.Config.Services.GoogleAnalytics.ID (ne (getenv "HUGO_ENV") "DEV") }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Config.Services.GoogleAnalytics.ID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.GoogleAnalytics }}');
gtag('config', '{{ .Site.Config.Services.GoogleAnalytics.ID }}');
</script>
{{ end }}
</head>
Expand Down

0 comments on commit fcf525f

Please sign in to comment.