Skip to content

footer.html Partial gets included twice, Tracking Code executed multiple times #574

@mrimann

Description

@mrimann

Describe the bug
I noticed in Matomo that each and every page view was tracked twiced. So opening the front page of my website ended up in two logged views. Opening a blog post does the same.

Could track it down to certain parts of the rendered HTML being dupliced in the output, because the footer.html partial is included twice, once in the sidebar.html where it IMO makes sense and the Footer "content" is also visible below the Sidebar - and also in the baseof.html file.

The latter leads to rendering the HTML code of the Footer-Partial at the end of the <body> tag - but it's not visible in the frontend.

Since the footer.html contains the include for the google-analytics-gtag-async.html partial (which I overwrote to contain the Matomo Tracking Tag instead of Google Analytics or GTag), this leads to having the <script>-Tag twice in the output, resulting in the mentioned double-tracking of each page view.

To Reproduce
Steps to reproduce the behavior:

  1. start the local preview of the demo site as describe in https://github.com/lxndrblz/anatole?tab=readme-ov-file#preview-the-example-site
  2. check the rendered HTML, the footer-block including the load of /js/medium-zoom.min(...).js is duplicated, see screenshot

Expected behavior
The footer partial should not be included twice.

Screenshots
Image

Additional context
I guess this is not a huge problem "out of the box" since adding multiple <script type="text/javascript" src="..."> does not do any harm as the Browser realizes that this is a request for the same asset and does not load it twice.

For testing if it alos behaves like with my Matomo Tracking-Code when the regular Google Tag Manager tracking code is used, I added

  • gtagId = "SOME_VALID_GTAG_ID" in params.toml
  • removed and (hugo.IsProduction) from footer.html

to simulate the behaviour on the preview site locally. Resulted in:

  • HTML is rendered twice
  • Google Tag Manager JS is loaded only once
  • but multiple Requests towards https://region1.google-analytics.com/g/collect(...) are fired!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions