# GoatCounter with gohugo-theme-ananke

**URL:** <https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938>\
**Category:** support\
**Tags:** analytics\
**Created:** [June 22, 2023, 5:47pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938 "2023-06-22T17:47:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DazWilkin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dazwilkin/32/9526_2.png) [@DazWilkin](https://discourse.gohugo.io/u/DazWilkin)\
**Post date:** [June 22, 2023, 5:47pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/1 "2023-06-22T17:47:22Z")

</div>

I’ve been using Google Analytics but looking to switch some sites to [GoatCounter](https://www.goatcounter.com/)

I’m using `gohugo-theme-ananke` as a Hugo Module

Cursory searches suggest1 that I could create `layouts/partials/analytics.htm` containing:

```plaintext
<script
    data-goatcounter="https://{site}.goatcounter.com/count"
    async src="//gc.zgo.at/count.js"
></script>

```

But this approach appears to not work:

1. There’s no obvious place to reference `analytics.html` after creation
2. The `<script>` isn’t included in the built site.

Apologies for finding this challenging…

1 [How to add GoatCounter to your Hugo website](https://robb.sh/posts/adding-goatcounter-analytics-to-hugo/)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 22, 2023, 6:11pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/2 "2023-06-22T18:11:37Z")

</div>

Override the theme’s baseof.html template, and place this within the `<head>` element:

```auto
{{ partialCached "analytics.html" . }}

```

Always use `.html` instead of `.htm` when naming templates.

---

<div class="post-metadata">

**Author:** ![DazWilkin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dazwilkin/32/9526_2.png) [@DazWilkin](https://discourse.gohugo.io/u/DazWilkin)\
**Post date:** [June 22, 2023, 6:39pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/3 "2023-06-22T18:39:40Z")

</div>

Thank you for the helpful reply.

How do I override the theme’s `baseof.html` template? Do I simply create a local copy of [baseof.html](https://github.com/theNewDynamic/gohugo-theme-ananke/blob/master/layouts/_default/baseof.html) and add the `{{ partialCached ... }}`? Will try that.

The `htm` (sic.) was a typo in my question; it is actually `html`.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 22, 2023, 6:40pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/4 "2023-06-22T18:40:21Z")

</div>

> [@DazWilkin](#):
>
> Do I simply create a local copy of [baseof.html](https://github.com/theNewDynamic/gohugo-theme-ananke/blob/master/layouts/_default/baseof.html)

Yes, place it in the layouts directory in the root of your project.

---

<div class="post-metadata">

**Author:** ![DazWilkin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dazwilkin/32/9526_2.png) [@DazWilkin](https://discourse.gohugo.io/u/DazWilkin)\
**Post date:** [June 22, 2023, 6:49pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/5 "2023-06-22T18:49:19Z")

</div>

I placed it under `./layouts/_default` and directly under `./layouts` with the same error.

> ERROR render of “page” failed: “/path/to/layouts/\_default/baseof.html:34:7”: execute of template failed: template: \_default/single.html:34:7: executing “\_default/single.html” at \<partialCached “layouts/partials/analytics.html” .\>: error calling partialCached: partial “layouts/partials/analytics.html” not found  
> Total in 162 ms  
> Error: error building site: render: failed to render pages: render of “page” failed: “/path/to/layouts/\_default/baseof.html:34:7”: execute of template failed: template: \_default/single.html:34:7: executing “\_default/single.html” at \<partialCached “layouts/partials/analytics.html” .\>: error calling partialCached: partial “layouts/partials/analytics.html” not found

Line #34: ` {{ partialCached "layouts/partials/analytics.html" . }}`

If I remove line #34, it builds successfully.

Ah… it appears it wants the local reference:

Line #34: ` {{ partialCached "analytics.html" . }}`

Thank you!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 22, 2023, 6:51pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/6 "2023-06-22T18:51:14Z")

</div>

Sorry, cut and paste. Glad it’s working for you.

---

<div class="post-metadata">

**Author:** ![DazWilkin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/dazwilkin/32/9526_2.png) [@DazWilkin](https://discourse.gohugo.io/u/DazWilkin)\
**Post date:** [June 22, 2023, 6:53pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/7 "2023-06-22T18:53:26Z")

</div>

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 24, 2023, 6:54pm UTC](https://discourse.gohugo.io/t/goatcounter-with-gohugo-theme-ananke/44938/8 "2023-06-24T18:54:00Z")

</div>

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