appernetic / hugo-nederburg-theme

Nederburg is a fast and secure hugo theme and is a port of the Tracks WP theme
Other
106 stars 86 forks source link

Disable GoogleAnalytics when not running in production #45

Open andretti1977 opened 5 years ago

andretti1977 commented 5 years ago

As in the title, it would be a good thing to disable GoogleAnalytics when not running in production. There are several ways to do this but the one i prefer is to check for the env var HUGO_ENV. Here user budparr suggests this code:

{{ if eq (getenv "HUGO_ENV") "production" }}
        {{ template "_internal/google_analytics_async.html" . }}
{{ end }}

You should simply change layouts/partials/head.html. I would do a pull request but since there are many ways to disable it and since that would force your user to provide that env var, i prefer you to solve the issue in the way you prefer

appernetic commented 5 years ago

Yes, I agree. I thought that there was a check for localhost in the internal Hugo file?