How to Add Orbit Analytics to a Hugo Site

Hugo generates static HTML from a set of shared templates, so the script only needs to go into one partial — the one that renders <head> — for it to appear on every page the build produces.

Setup steps

  1. Locate your head partialMost Hugo themes include a shared partial such as layouts/partials/head.html that every page template calls to render the <head> section.
  2. Open head.htmlIf your theme doesn't expose one directly, check layouts/_default/baseof.html for where <head> is defined, or create a partial override in your own layouts/partials/ directory.
  3. Add the script tagPaste the Orbit <script defer src="https://orbitanalytics.app/script.js" data-website-id="{id}"></script> tag before the closing </head> in that partial.
  4. Rebuild the siteRun hugo (or your usual build command) to regenerate the static HTML with the script included on every page, then redeploy the output.

Frequently asked questions

Will editing head.html get overwritten when I update my theme?

It can, if the theme is a git submodule replaced wholesale on update. Overriding the partial in your own project's layouts/partials/ directory, rather than editing the theme's copy directly, survives theme updates since Hugo checks your project first.

Does this work with Hugo's multilingual sites?

Yes — since the head partial is typically shared across all language versions of a page, the script tag is included regardless of which language a visitor views.

Should this go in config.toml instead?

No — config.toml controls site configuration and build behavior, not raw HTML output. The script tag has to go into a template file that actually renders <head>.

Does this affect Hugo's build speed?

No — adding one static script tag to a template has no measurable effect on Hugo's build time, which is dominated by content processing, not head-tag size.

See it on your own site

Free for 1 website, no card required.