How to Disable Tracking on Specific Pages in Hugo with Plausible

Add plausible_do_not_track: true to a page’s front matter to prevent the Plausible analytics script from loading on that specific page.

The divinerites/plausible-hugo module provides a built-in opt-out mechanism that lets you exclude individual pages or entire content sections from analytics tracking without disabling global site statistics. This is controlled through a conditional check in the head partial that respects a front-matter flag.

How the Plausible-Hugo Module Controls Tracking

The module injects the Plausible tracking script via the layouts/partials/plausible_head.html partial. This partial contains a conditional guard that determines whether to render the script tag:

{{- if and (site.Params.plausible.enable) (not .Params.plausible_do_not_track) }}

This logic requires two conditions to be true for tracking to activate:

  1. Global enablement: The site configuration parameter site.Params.plausible.enable must be set to true.
  2. No opt-out flag: The page parameter .Params.plausible_do_not_track must not be set to true.

When a page sets plausible_do_not_track: true, the second condition fails, the and logic returns false, and the partial skips rendering the Plausible script element entirely.

Disabling Tracking with Front Matter

You can disable tracking on specific pages by adding the plausible_do_not_track key to the page’s YAML front matter.

Single Page Opt-Out

To exclude a single page—such as a privacy policy, terms of service, or internal admin page—add the flag to that file’s front matter:

---
title: "Privacy Policy"
date: 2024-02-28
plausible_do_not_track: true
---

Your privacy policy content here...

When Hugo renders this page, the plausible_head.html partial detects the flag and omits the tracking script from the HTML <head>.

Section-Wide Opt-Out

To disable tracking for an entire content section—such as all draft posts, archived content, or a specific language branch—set the flag in the section’s _index.md file. Hugo’s front-matter inheritance passes this parameter down to all child pages in that section.

For example, to exclude all pages under content/drafts/:

---
title: "Drafts"
plausible_do_not_track: true
---

All pages located in content/drafts/ or its subdirectories will inherit plausible_do_not_track: true, causing the Plausible script to be excluded from each page’s output.

Verifying Tracking is Disabled

To confirm that the opt-out is working correctly:

  1. Build your site using hugo server or hugo --minify.
  2. View the page source of the excluded page (right-click → View Page Source).
  3. Search for the Plausible script. You should not see a <script> tag with src containing plausible.io or your self-hosted domain.
  4. Check a tracked page to ensure the script appears there, confirming global settings remain intact.

If the script still appears on an excluded page, verify that the front-matter key is exactly plausible_do_not_track (case-sensitive) and that there are no indentation errors in your YAML.

Summary

  • Front-matter flag: Set plausible_do_not_track: true in any page’s YAML to exclude it from Plausible analytics.
  • Inheritance: Place the flag in a section’s _index.md to disable tracking for all pages in that branch.
  • Mechanism: The plausible_head.html partial checks this flag before rendering the tracking script tag.
  • Verification: Inspect the rendered HTML to confirm the absence of the Plausible script element on excluded pages.

Frequently Asked Questions

What is the exact front matter key to disable tracking?

The exact key is plausible_do_not_track. It must be set to true in the page’s YAML front matter. The plausible-hugo partial specifically checks for .Params.plausible_do_not_track, so any deviation in spelling or casing will not trigger the opt-out.

Can I disable tracking for an entire section of my Hugo site?

Yes. By adding plausible_do_not_track: true to the _index.md file of a content section, all pages within that section inherit the parameter. This leverages Hugo’s built-in front-matter inheritance to disable the Plausible script across entire directories without editing individual files.

How do I confirm that a page is not being tracked?

View the source HTML of the rendered page and search for the Plausible script tag. If the opt-out is active, you will not find a <script> element containing plausible.io or your custom domain. Additionally, the Network tab in browser developer tools will show no request to the Plausible event endpoint when you navigate the page.

Does disabling tracking on specific pages affect my global Plausible configuration?

No. The plausible_do_not_track flag is strictly an opt-out mechanism for individual pages. Your global settings in hugo.toml or config.yaml—including site.Params.plausible.enable—remain unchanged and continue to inject the tracking script on all pages that do not explicitly set the opt-out flag.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →