Hugo generates two Google Analytics js

After inserting the Google Analytics code into config.toml → googleAnalytics = "xxx"

Hugo generates two js links:

<head>
<script async src="https://www.google-analytics.com/analytics.js"></script>
...
<script type="application/javascript">...</script>
<script type="application/javascript">...</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
</head>

Is this normal that two async links are generated on top and bottom of head tag?

Many Thanks,
Houman

Difficult to say without seeing the head template of your project.
Most likely you are calling the GA code twice.

If the issue persists you will need to share the project or a project with dummy content that reproduces the issue.

Thank you for your support.

I was just able to reproduce it easily.

1) Download the Vex-hugo https://github.com/themefisher/vex-hugo.git
2) vim ./vex-hugo/exampleSite/config.toml
and change googleAnalytics = "UA-111111111-1" and save.
3) cd ./vex-hugo/exampleSite
4) hugo server --themesDir ../..

Now check the source code of homepage and you will see the duplication.

Many Thanks,
Houman

You need to talk to the theme authors. Please file an issue at the theme repo.

Unless @gethugothemes replies to you here.

Thanks, Done: Vex-hugo generates two analytics.js in source · Issue #25 · themefisher/vex-hugo · GitHub

@alexandros thanks for mentioning us . We already fixed his issue in github.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.