Adding plausible.io analytics to Hugo
Overview
This year (2021) I removed Google Analytics and Disqus from my Hugo managed website to enhance the privacy of visitors. Site statistics is not a requirement, I am not selling anything or making an attempt to optimize readership. However, it is nice to know what people are interested in reading. At some point I may try to tailor content that is more interesting to my readers instead of whatevers top of mind for the day.
This post details what it takes to configure and install the hosted version of Plausible within the Hugo. I thought about self-hosting, but I would rather support quality software.
Details
As noted above, Hugo is the website content management framework.
Plausible recommends using the plausible-hugo Hugo theme. For those managing themes with git
, clone the module with the submodule
option:
cd themes
git submodule add https://github.com/divinerites/plausible-hugo.git
Add plausible-hugo
to the theme
variable in the config.toml
file:
theme = ["hermit", "plausible-hugo"]
Enable analytics on all pages, overriding the Hermit
theme <head>
section by adding (or creating) the following line to layouts/partials/extra-head.html
:
{{ partial "plausible_head.html" . }}
While loading speed is not an issue for this site, Plausible is the main contributor of load time:
I enable public statistics, browse to https://plausible.io/jasonmurray.org