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

Google Analytics doesn't work on latest version #1386

Closed
knzhou opened this issue Oct 13, 2019 · 5 comments
Closed

Google Analytics doesn't work on latest version #1386

knzhou opened this issue Oct 13, 2019 · 5 comments

Comments

@knzhou
Copy link

knzhou commented Oct 13, 2019

I updated to the latest version from a one-year old version, and Google Analytics stopped working. This can be easily reproduced:

  1. Create a new website following standard instructions, by cloning sourcethemes/academic-kickstart
  2. Set google_analytics = "UA-123456789-1" in params.toml
  3. Run hugo (basic install of latest version 0.58.3), site created in public folder
  4. Analytics code snippet not included in the website files; to double check, grep 123456789 public -r returns no results

I don't think this is an issue with running in production. I'm not using netlify at all, I'm just running the command hugo (not hugo server) locally.

@gcushen
Copy link
Collaborator

gcushen commented Oct 14, 2019

Closing as duplicate - search to see other issues on this.

You can read more in the release notes too: https://sourcethemes.com/academic/updates/v4.6.0/

Essentially it sounds like you haven't set the Hugo environment - see Hugo docs/forums for more.

@gcushen gcushen closed this as completed Oct 14, 2019
@knzhou
Copy link
Author

knzhou commented Oct 14, 2019

I don't think it's a duplicate. The environment is the first thing I checked. The problem persists even if I build with hugo -e production.

@gcushen
Copy link
Collaborator

gcushen commented Oct 14, 2019

You can set HUGO_ENV to production in case there is a Hugo bug with -e - see Hugo docs/forums for details.

@nurfatimaj
Copy link

I thought I could share in case it could point to some solution. I am quite a beginner myself, but I had same issue. In my understanding, the problem narrowed down to not being able to get past
{{ if eq (getenv "HUGO_ENV") "production }}
condition. However, when I amended it to
{{ if eq (hugo.Environment) "production" }} I think it worked. At least I could see the respective script tags in the page source.

@gcushen
Copy link
Collaborator

gcushen commented Oct 25, 2019

@labuve see my response above on setting HUGO_ENV (see Hugo docs on how to set it).

Also, there appears to be a bug with hugo.Environment. I have opened a Hugo bug report on this - please consider to vote it up if it affects you: gohugoio/hugo#6456

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

3 participants