From f6a183a5c370db0698938328fa3e505c4be19f16 Mon Sep 17 00:00:00 2001 From: panda-z Date: Tue, 12 May 2020 22:27:09 +0800 Subject: [PATCH] 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`. --- layouts/partials/scripts.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }} -{{- 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 -}}