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

github.com/halogenica/beautifulhugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNina Zakharenko <nzakharenko@gmail.com>2019-07-14 05:07:32 +0300
committerMichael Romero <halogenica@users.noreply.github.com>2022-06-26 09:59:09 +0300
commitec8f709bfb9b2a98285125df9fb3f3fe02e08a9e (patch)
tree70642bb626d928de80affc761dd3eba71e20624b
parent07f765675dab2b00ad39aa460118edff2f2d3fcd (diff)
Don't use google analytics when running on built-in server
-rw-r--r--README.md2
-rw-r--r--layouts/partials/head.html4
2 files changed, 5 insertions, 1 deletions
diff --git a/README.md b/README.md
index 63657e9..7afbdac 100644
--- a/README.md
+++ b/README.md
@@ -105,6 +105,8 @@ comments:
To add Google Analytics, simply sign up to [Google Analytics](https://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `googleAnalytics` parameter in `config.toml`.
+Note that the Google Analytics tracking code will only be inserted into the page when the site isn't served on Hugo's built-in server, to prevent tracking from local testing environments.
+
### Commit SHA on the footer
If the source of your site is in a Git repo, the SHA corresponding to the commit the site is built from can be shown on the footer. To do so, two environment variables have to be set (`GIT_COMMIT_SHA` and `GIT_COMMIT_SHA_SHORT`) and parameter `commit` has to be defined in the config file:
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 2c872b4..02c3928 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -108,4 +108,6 @@
{{- end -}}
{{- partial "head_custom.html" . }}
-{{ template "_internal/google_analytics_async.html" . }}
+{{- if not .Site.IsServer -}}
+ {{ template "_internal/google_analytics_async.html" . }}
+{{- end -}} \ No newline at end of file