diff --git a/.gitignore b/.gitignore index 8ab22c224..5208c5c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,3 @@ node_modules/ nohup.out package-lock.json trace.out -assets/jsconfig.json - diff --git a/assets/js/main.js b/assets/js/main.js index 8c8ea6247..c12be19fa 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -48,7 +48,6 @@ var debug = 0 ? console.log.bind(console, '[index]') : function () {}; { let containerScrollTops = {}; - let turboLoaded = false; // To preserve scroll position in scrolling elements on navigation add data-turbo-preserve-scroll-container="somename" to the scrolling container. addEventListener('turbo:click', () => { @@ -57,14 +56,6 @@ var debug = 0 ? console.log.bind(console, '[index]') : function () {}; }); }); - addEventListener('turbo:load', () => { - if (turboLoaded) { - // Minimal Analytics does not support SPA out of the box, so we need to manually track page views on Turbo navigation. - window.track('page_view'); - } - turboLoaded = true; - }); - addEventListener('turbo:render', () => { document.querySelectorAll('[data-turbo-preserve-scroll-container]').forEach((ele) => { const containerScrollTop = containerScrollTops[ele.dataset.turboPreserveScrollContainer]; diff --git a/assets/jsconfig.json b/assets/jsconfig.json new file mode 100644 index 000000000..377218ccb --- /dev/null +++ b/assets/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "*": [ + "*" + ] + } + } +} \ No newline at end of file diff --git a/go.mod b/go.mod index fa2ea19f8..4b9e0a369 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,3 @@ module github.com/gohugoio/hugoDocs go 1.22.0 - -require ( - github.com/bep/hugo-mod-minimalanalytics v0.3.0 // indirect - github.com/jahilldev/minimal-analytics v0.0.0-20220825110705-ee335ed38334 // indirect -) diff --git a/go.sum b/go.sum index f753f06a0..af9b5febf 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,2 @@ -github.com/bep/hugo-mod-minimalanalytics v0.3.0 h1:fctZN3nFOFrapX1dhPBszyCUKOGjEpBJmp1jBf3YkJE= -github.com/bep/hugo-mod-minimalanalytics v0.3.0/go.mod h1:3QVkKqSikBRTI+hS3dm/zCAfGukd+opSfAwfjkyxqIw= -github.com/jahilldev/minimal-analytics v0.0.0-20220825110705-ee335ed38334 h1:r8/jLqGw5uwSmgJ4eSGbxa1XBaSIkp3MY99GhY61NeE= -github.com/jahilldev/minimal-analytics v0.0.0-20220825110705-ee335ed38334/go.mod h1:w4l2fXZWGxmcVQfLLBdTqUT6HpSIA9FhmUtVArJFLYw= +github.com/gohugoio/gohugoioTheme v0.0.0-20250116152525-2d382cae7743 h1:gjoqq8+RnGwpuU/LQVYGGR/LsDplrfUjOabWwoROYsM= +github.com/gohugoio/gohugoioTheme v0.0.0-20250116152525-2d382cae7743/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM= diff --git a/hugo.toml b/hugo.toml index 3cd51c4e8..5e0b697ef 100644 --- a/hugo.toml +++ b/hugo.toml @@ -98,8 +98,6 @@ ignoreLogs = ['warning-frontmatter-params-overrides'] disableWatch = true source = "hugo_stats.json" target = "assets/notwatching/hugo_stats.json" - [[module.imports]] - path = "github.com/bep/hugo-mod-minimalanalytics" [outputFormats] [outputFormats.redir] @@ -122,11 +120,6 @@ ignoreLogs = ['warning-frontmatter-params-overrides'] [params] description = "The world’s fastest framework for building websites" ghrepo = "https://github.com/gohugoio/hugoDocs/" - - [params.minimalanalytics] - # GA4 tracking ID - tracking_id = "G-MBZGKNMDWC" - [params.render_hooks.link] errorLevel = 'warning' # ignore (default), warning, or error (fails the build) [params.social.mastodon] @@ -155,6 +148,10 @@ ignoreLogs = ['warning-frontmatter-params-overrides'] [[server.headers]] for = "/**.{css,js}" +[services] + [services.googleAnalytics] + ID = 'G-MBZGKNMDWC' + [taxonomies] category = 'categories' diff --git a/layouts/_partials/helpers/gtag.html b/layouts/_partials/helpers/gtag.html new file mode 100644 index 000000000..59bf36ba2 --- /dev/null +++ b/layouts/_partials/helpers/gtag.html @@ -0,0 +1,27 @@ +{{ with site.Config.Services.GoogleAnalytics.ID }} + + +{{ end }} diff --git a/layouts/_partials/layouts/head/head-js.html b/layouts/_partials/layouts/head/head-js.html index e24c10ce8..d83efcd0f 100644 --- a/layouts/_partials/layouts/head/head-js.html +++ b/layouts/_partials/layouts/head/head-js.html @@ -1,6 +1,3 @@ -{{ if or hugo.IsProduction (not hugo.IsDevelopment) }} - {{ partial "minimalanalytics.html" . }} -{{ end }} {{ $githubInfo := partialCached "helpers/funcs/get-github-info.html" . "-" }} {{ $opts := dict "minify" true }} {{ with resources.Get "js/head-early.js" | js.Build $opts }} diff --git a/layouts/_partials/layouts/head/head.html b/layouts/_partials/layouts/head/head.html index 7014e2c29..265d7ccd0 100644 --- a/layouts/_partials/layouts/head/head.html +++ b/layouts/_partials/layouts/head/head.html @@ -36,3 +36,6 @@ {{ partial "schema.html" . }} {{ partial "twitter_cards.html" . }} +{{ if hugo.IsProduction }} + {{ partial "helpers/gtag.html" . }} +{{ end }} diff --git a/layouts/_partials/layouts/home/sponsors.html b/layouts/_partials/layouts/home/sponsors.html index 5832e9770..1f391e1ec 100644 --- a/layouts/_partials/layouts/home/sponsors.html +++ b/layouts/_partials/layouts/home/sponsors.html @@ -15,9 +15,13 @@ {{ $url = printf "%s?%s%s" .link $query_params (querify "utm_source" (.utm_source | default $utmSource ) "utm_medium" (.utm_medium | default "banner") "utm_campaign" (.utm_campaign | default "hugosponsor") "utm_content" (.utm_content | default "gohugoio")) | safeURL }} {{ end }} {{ $logo := resources.Get .logo }} + {{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }}