Simplytics

Add analytics to Hugo with a 1.2 KB cookieless tag

To add analytics to Hugo, put one <script> tag inside <head> in your base template, layouts/baseof.html. Copy your theme's baseof.html into your own layouts/ folder first so a theme update can't wipe it, then paste the tag before </head>. For Simplytics that tag is ~1.2 KB gzipped and sets no visitor cookies.

Hugo builds plain static HTML with a full page load on every click, so one tag in <head> counts every view. There is no route-change code to write.

Where does the analytics tag go in Hugo?

This is the tag, with your site key in data-key:

<script async src="https://simplytics.dev/track.js" data-key="YOUR_KEY"></script>

YOUR_KEY is the public site key from your dashboard, so it is safe to commit.

Hugo has no plugin system, and its one built-in analytics template ({{ partial "google_analytics.html" . }}) is Google-only. So the tag goes straight into the <head> your theme renders. Three ways to get it there:

Method Works with Survives theme updates?
Copy baseof.html into your layouts/ Any theme Yes
Theme's custom-head partial or config key Themes that offer one Yes
Edit the theme's own files Any theme No — an update overwrites them

The method that works with any theme

Your project's layouts/ overrides the theme's, file for file, so a copy in your project always wins:

  1. Find your theme's base template at themes/<theme>/layouts/baseof.html.
  2. Copy it to layouts/baseof.html in your project root.
  3. Paste the Simplytics tag on its own line just before </head>.
  4. Run hugo, or restart hugo server, and reload.

Hugo 0.146 reorganised the layouts folder: the base template is now layouts/baseof.html and partials live in layouts/_partials/. Before 0.146 these were layouts/_default/baseof.html and layouts/partials/ — Hugo still maps the old names, but lists moving them as a required migration, so use the new paths.

Do not just create layouts/_partials/head.html. If your theme already ships a head.html partial, your file replaces it wholesale and you lose the theme's title, styles and meta tags. Build a head partial from scratch only when your theme has none.

Many themes save you the copy: they read a custom-head partial or a config key for exactly this. Check your theme's docs for a "custom head", "extra head" or "analytics" setting first — it survives updates and is less to maintain.

How do I keep my own visits out of the numbers?

Use either:

How do I check the first hit?

  1. Deploy, then open a page on your live site. Views from localhost or hugo server are refused, because the hostname has to match a site on your account.
  2. In DevTools, open Network and filter for track. You should see a POST to https://simplytics.dev/track that returns {"status":"success"}.
  3. View the page source and confirm the track.js tag is inside <head>.
  4. Open your dashboard. The site shows as verified once a valid hit arrives. On a new account, that first view starts the 30-day free trial, no card needed.

Nothing in Network? If your site sends a Content-Security-Policy, add https://simplytics.dev to both script-src and connect-src. Brave and DuckDuckGo send Global Privacy Control by default, so the tag sends nothing in those browsers and your own test can look like a broken install.

When another tool fits better

Simplytics is cookieless like Plausible and Fathom. It differs on price — $1/month, billed yearly ($12/year for unlimited sites and pageviews, with a 30-day trial and no card), against Plausible's $9/month — on a primary analytics database in Warsaw, and on raw rows deleted nightly with no scheduled expiry for the daily totals you keep. Compare Simplytics vs Plausible, try the demo, or see pricing.

Installing elsewhere? See Astro and WordPress without a plugin.

Hugo behaviour verified against Hugo 0.169.0. Last verified: 2026-10-28.

← All posts