OneTag AI / Guides

Add AI to a Hugo site

How do I add an AI feature to a Hugo site?

Hugo generates pages in milliseconds and serves them from anywhere. The flip side: there is nowhere to run a proxy for an AI API, so most "add AI to Hugo" tutorials end with a Netlify or Cloudflare function and a secret key to manage.

With OneTag AI the key is public and budgeted, so it goes straight into a partial. This guide adds the tag through layouts/partials/head.html and a summary button to the single-page template.

Steps

  1. Get a free key

    From onetagai.com.

  2. Add the tag in a head partial

    Create or edit layouts/partials/head.html (most themes let you override it under layouts/partials/ in your site, not the theme folder):

    <script src="https://onetagai.com/v1.js" data-key="YOUR_ONETAG_KEY"></script>

  3. Add a button to the post template

    In layouts/_default/single.html, below the content:

    <button id="tldr">TL;DR</button>
    <p id="summary"></p>
    <script type="module">
      document.getElementById("tldr").onclick = async () => {
        const out = document.getElementById("summary");
        out.textContent = "";
        await onetag.ask("Summarize in 3 bullets", document.querySelector(".post-content"), {
          stream: (d) => { out.textContent += d; },
        });
      };
    </script>

  4. Build

    hugo or hugo server. Nothing else changes: no modules, no config entries, no environment variables.

Keeping the key in config

If you would rather not hard-code it, put onetagKey = "ot_…" under [params] in hugo.toml and render data-key="{{ .Site.Params.onetagKey }}" in the partial. Themes can then expose it as an option.

Theme authors

A theme can ship this as an opt-in feature: render the tag only when .Site.Params.onetagKey is set, and the summary button or a question box only on pages where the key exists. Users who want it get one line of config; everyone else sees nothing.

Multilingual sites

For a site that exists in one language, a "translate this page" link is the cheapest second language: onetag.ask("Translate to Japanese", document.querySelector(".post-content")). The translate guide covers streaming the translation into the page and keeping the original.

Questions

Does the theme need to support this?

No. Any theme that lets you override a head partial works. If yours does not, put the tag in a custom layout or in layouts/partials/extend_head.html, which many themes include.

Will Hugo's asset pipeline try to process the script?

No. A plain script tag in a template is copied through untouched. Do not pass it through resources.Get; it is an external file.

Does it work with Hugo's --minify?

Yes. Minification keeps script tags and their attributes.

Is it safe to put the OneTag AI key in my page?

Yes, it is designed for that. The key can only spend its own token budget and cannot read or change anything on your account. On the Pro plan you can lock it to your domain so other sites cannot use it; free keys work from any page.

Does it cost anything?

A free key has 1,000,000 tokens with no monthly reset, enough for a few hundred summaries. Pro is $9.9 a month for 100,000,000 tokens a month and the domain lock.

Which model answers?

A fast, inexpensive model from OpenRouter, chosen for sub-second first tokens and good instruction following. You do not pick a model; the point is one tag that keeps working.

What happens to the text my visitors send?

It goes to the model and comes back. OneTag AI stores token counts per key for the quota and keeps no prompts, inputs or answers. The access log carries no IP addresses.

Try it on your sitefree

Get a free key by email, paste one tag, call onetag.ask. 1,000,000 tokens, no card.

Get a free key

Updated 2026-11-09. Something wrong or missing? Email support@odysseyx.app.