diff options
author | John Hollowell <johnahollowell@gmail.com> | 2020-05-05 03:09:33 +0300 |
---|---|---|
committer | Julian <julian@vantage-design.com> | 2020-05-11 15:43:27 +0300 |
commit | ffa487e0bf1a7637c990cd72145725f214f03032 (patch) | |
tree | 86620e9a4d9345f78bd32f0a5d677c0389f77faa /layouts | |
parent | 2582f9d8a095900d94b20a5d9c7d389a47fcd23a (diff) |
Allow Google Analytics to only track production site
prevents loading the google analytics internal partial unless the system is in "production" mode
`hugo` defaults to "production".
* Any command can add `--environment production` to the hugo command
* OR add HUGO_ENVIRONMENT="production" to the shell running hugo
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/head.html | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e2b6a5a..1e7e079 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -17,6 +17,9 @@ {{ $style := resources.Get "css/ace.scss" | toCSS | minify }} <link rel="stylesheet" href="{{ $style.Permalink }}"> - {{ template "_internal/google_analytics_async.html" . }} + <!-- Only include the tracking when using `hugo` or adding `--environment production` --> + {{ if eq hugo.Environment "production" }} + {{ template "_internal/google_analytics_async.html" . }} + {{ end }} </head> |