diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 23e6ffc571..fe208c6895 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -7,7 +7,7 @@
{{ end -}}
-{{ if and (eq (getenv "HUGO_ENV") "production") (ne $outputFormat "print") -}}
+{{ if and hugo.IsProduction (ne $outputFormat "print") -}}
{{ else -}}
@@ -45,7 +45,7 @@
{{ end }}
{{ partial "hooks/head-end.html" . }}
-{{ if eq (getenv "HUGO_ENV") "production" }}
+{{ if hugo.IsProduction }}
{{ if hasPrefix .Site.GoogleAnalytics "G-"}}
{{ template "_internal/google_analytics.html" . }}
{{ else }}