From 32dbb9c716d46c000e8ba55ce4e43ca812241622 Mon Sep 17 00:00:00 2001
From: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date: Sun, 12 Jul 2026 11:37:04 +0000
Subject: [PATCH] fix: guard footer scripts with Scratch to prevent double-tracking
---
layouts/partials/footer.html | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 8cedb9d..dc543de 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -41,10 +41,13 @@
{{ end }}
</ul>
</footer>
-{{- partial "medium-zoom.html" .context -}}
-{{- if (hasPrefix .context.Site.Config.Services.GoogleAnalytics.ID "G-") -}}
- {{- template "_internal/google_analytics.html" .context -}}
-{{- end -}}
-{{- if and (hugo.IsProduction) (.context.Site.Params.gtagId) -}}
- {{ partial "google-analytics-gtag-async.html" .context }}
+{{- if not (.context.Scratch.Get "footerScriptsRendered") -}}
+ {{- .context.Scratch.Set "footerScriptsRendered" true -}}
+ {{- partial "medium-zoom.html" .context -}}
+ {{- if (hasPrefix .context.Site.Config.Services.GoogleAnalytics.ID "G-") -}}
+ {{- template "_internal/google_analytics.html" .context -}}
+ {{- end -}}
+ {{- if and (hugo.IsProduction) (.context.Site.Params.gtagId) -}}
+ {{ partial "google-analytics-gtag-async.html" .context }}
+ {{- end -}}
{{- end -}}
--
Gitblit v1.10.0