Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable GoogleAnalytics when not running in production #45

Open
andretti1977 opened this issue Sep 26, 2018 · 1 comment
Open

Disable GoogleAnalytics when not running in production #45

andretti1977 opened this issue Sep 26, 2018 · 1 comment

Comments

@andretti1977
Copy link
Contributor

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant