diff options
author | panda-z <panda.hust@gmail.com> | 2020-05-12 22:27:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 22:27:09 +0800 |
commit | f6a183a5c370db0698938328fa3e505c4be19f16 (patch) | |
tree | 72f69cc3ced760988f0709dd6a6d170801459d3e /layouts | |
parent | 50aa3f8d5553fdbd0e05db7a2c3351d1d593af29 (diff) |
feat(scripts): only enable google analytics in production environment (#260)
Should set env to production, e.g.: `hugo serve -e production`
Default environments are **development** with `hugo serve` and **production** with `hugo`.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/scripts.html | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 5a705da..898bbc4 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -93,7 +93,7 @@ {{- end }} <!-- Analytics --> -{{- if and (not .Site.IsServer) .Site.GoogleAnalytics -}} +{{- if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") | and .Site.GoogleAnalytics -}} {{ template "_internal/google_analytics_async.html" . }} {{- end -}} |