How integrate Plausible into Hugo


I am trying Plausible, and - according to their instructions - after installing the theme, I created the file plausible_head.html, under /layout/partial with the script like the following:

<script defer data-domain="" src=""></script>

In the file (the home page), I I made two attempts trying to add the snippet as

   {{ partial "plausible_head.html" . }}

and also as

{{ partial "plausible_head.html" . }}

In both those cases, it doesn’t work.

Where am I wrong?

If you follow their (my ?? :grin:) instruction you do not have to create the file plausible_head.html
It is much simpler.

Just do this :

Add this plausible-hugo component as a theme in your theme section in config.toml.
Add a [params.plausible] section in your config.toml file.
Call the partial plausible_head.html in your own <head> section.

First of all, sorry; I confused your theme with one developed by Plausible.

I did exactly as you said, but it doesn’t work.
My home page ( starts with a <h1> title in mmd # Title.
If I put

   {{ partial "plausible_head.html" . }}

In the beginning, before the # Title Hugo marks it as an error, and it’s impossible the deployment.

Instead, If I put only the snippet {{ partial "plausible_head.html" . }} after the # Title I will see the snippet as a piece of text.

What can I do?

No you didn’t.

The <head> section already exists in your site in your existing partials (.html files in /layout/partials/).
You have to find it and add the line there.

You SHOULD NOT CREATE a new <head> section. And especially NOT in the content files.

Just do exacttly what I wrote.

1 Like