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`.
This commit is contained in:
panda-z 2020-05-12 22:27:09 +08:00 committed by GitHub
parent 50aa3f8d55
commit f6a183a5c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -93,7 +93,7 @@
{{- end }} {{- end }}
<!-- Analytics --> <!-- 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" . }} {{ template "_internal/google_analytics_async.html" . }}
{{- end -}} {{- end -}}