Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/papercss-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Freitas <joao.mag.freitas@gmail.com>2022-01-08 22:56:52 +0300
committerGitHub <noreply@github.com>2022-01-08 22:56:52 +0300
commit48925ee69fddcadfa820bbcbdbbad760b46652ef (patch)
tree046736883cf32695a93e25a8fef31727304d0976
parentcd81179a5abbe8915879b1a5c9eec58757aaad84 (diff)
Bugfix: Correct Google Analytics usage (#14)HEADmaster
* Remove outdated google-analytics partial template * Remove outdated google analytics partial template usage * Usage of current supported google analytics partial template + disabling google analytics in non production environments * Make sure Google Analytics v3 partial template is used if v4 ID is not provided * Update layouts/partials/head.html Co-authored-by: zwbetz-gh <37317628+zwbetz-gh@users.noreply.github.com> * Remove unecessary v4 & v3 conditions as the original template already does them * Update head.html Co-authored-by: zwbetz-gh <37317628+zwbetz-gh@users.noreply.github.com>
-rw-r--r--layouts/_default/baseof.html3
-rw-r--r--layouts/partials/google-analytics-async.html10
-rw-r--r--layouts/partials/head.html6
3 files changed, 6 insertions, 13 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 40335dc..8b3705f 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -7,7 +7,6 @@
<main>
{{ block "main" . }}{{ end }}
</main>
- {{ partial "google-analytics-async.html" . }}
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/layouts/partials/google-analytics-async.html b/layouts/partials/google-analytics-async.html
deleted file mode 100644
index ecc2767..0000000
--- a/layouts/partials/google-analytics-async.html
+++ /dev/null
@@ -1,10 +0,0 @@
-{{ if not .Site.IsServer }}
- {{ with .Site.GoogleAnalytics }}
- <script>
- window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
- ga('create', '{{ . }}', 'auto');
- ga('send', 'pageview');
- </script>
- <script async src='https://www.google-analytics.com/analytics.js'></script>
- {{ end }}
-{{ end }} \ No newline at end of file
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 68540ee..009893f 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -29,10 +29,14 @@
{{ $customCssPath := "css/custom.css" }}
{{ $customCss:= resources.Get $customCssPath | resources.ExecuteAsTemplate $customCssPath . }}
<link rel="stylesheet" type="text/css" href="{{ $customCss.RelPermalink }}">
+
+ {{ if hugo.IsProduction }}
+ {{ template "_internal/google_analytics.html" . }}
+ {{ end }}
{{ $title := print .Title " | " .Site.Title }}
{{ if .IsHome }}
{{ $title = .Site.Title }}
{{ end }}
<title>{{ $title }}</title>
-</head> \ No newline at end of file
+</head>