AI-agent support
llms.txt index, so AI agents and chat assistants can read the site without scraping its HTML.More and more of your readers arrive through a language model: a coding agent looking up an option, or a person pasting a page into a chat to ask about it. An HTML page is a poor source for them, because the sidebar, scripts and styles have to be stripped away before the content appears, and what survives is a lossy copy. OINK can publish the same content as plain Markdown instead, so a model reads exactly what you wrote and spends its context on the content.
Three outputs do this: a .md file beside every page, an llms.txt index at
the site root that tells an agent what the site contains, and a
Copy Markdown button on each page. All three are files written at build
time, so they need no runtime service and no content negotiation. The theme
turns none of them on; you list them under outputs. Two more outputs serve an
agent that reads more than one page: a full-text bundle per top-level section
and a navigation tree per language.
A .md per page
markdown is one of Hugo’s built-in output formats. Add it to every page kind
that should have one:
This is the configuration this site uses. Each key under outputs
replaces the list for that page kind rather than adding to it, so keep
every format the kind already had, such as RSS and print; a format you
leave out is no longer published.
The Markdown file sits at the page URL plus index.md:
| Page | Markdown |
|---|---|
/docs/customize/agents/ |
/docs/customize/agents/index.md |
/docs/customize/ (section index) |
/docs/customize/index.md |
/ (site home) |
/index.md |
Every HTML page also announces its Markdown version in <head>, so a crawler
does not have to guess the URL:
What the .md contains
The file holds the source you wrote, not a conversion of the rendered
HTML. The title becomes an H1 and the description a blockquote, then the
body follows as written, with shortcodes expanded in place into their Markdown
forms:
Native Markdown components keep their source: callouts, tables, field lists,
image attribute lines, code fences and data fences reach the model exactly as
you wrote them. A section index adds a Section pages: list of links to its
children after the body, and when backlinks
are on, a page ends with a Backlinks: list. Every list and label in the file
is in the page’s language.
Each shortcode has a defined Markdown form. A badge
becomes emphasized text or a link, a key becomes
Ctrl + K, tabs become consecutive **Label**
subsections, and fields become an item list. Each
component page gives its own form in its Output section.
The LLMS index: line appears only when the site publishes llms.txt, so the
file never links to something that does not exist.
llms.txt
llms.txt is a convention for a small plain-text map
at the site root: an agent fetches one file and learns what the site contains
and where the Markdown versions are. Add the LLMS output format to the
home page to publish it:
A multilingual site gets one per language, /llms.txt and
/zh/llms.txt, each generated from the site’s structure:
- Site index lists this language’s home page, its
navigation.jsonwhen the site publishes one, and the entries of the main menu (menus.main), linking each entry’s Markdown version when it has one and adding itsdescription. - Documentation index lists every page of the documentation section, each
indented under its subsection and followed by its
description. - Full-text bundles appears when at least one section publishes a bundle.
- Site locales lists every configured language.
Menu entries that point off the site, such as GitHub or an issue tracker, are
left out: they are navigation, not content. So to improve llms.txt, edit the
main menu and each page’s description; the template rarely needs to change.
Full-text bundle
A .md per page suits an agent that knows which page it wants. An agent that
needs the whole manual would otherwise crawl it page by page. The LLMSFULL
output gives it one file instead: an llms-full.txt per top-level section,
holding every page of that section in reading order.
You turn it on in the section index’s own front matter, not in the site configuration:
Front matter outputs replaces the site-level list for that page, so repeat
the formats the section already had; leave out markdown or print and the
section index loses them. Front matter is per language, so a bilingual site
repeats the line in _index.zh.md to get the Chinese bundle.
Each language gets one file at the section root, /docs/llms-full.txt and
/zh/docs/llms-full.txt, in the order of the sidebar and pager: the explicit
data/docs_nav.json tree for a docs or book section that has one, and the
weighted content tree otherwise. Pages hidden from the sidebar with toc_hide
are left out of the bundle too.
A separator line with the source URL introduces each page, and the body that
follows is byte for byte that page’s own .md:
Source: points at the page’s Markdown output, or at its HTML URL when the
page publishes no .md.
Only a top-level section can publish a bundle. Listed further down the tree,
LLMSFULL produces a warning (“LLMSFULL output requires a top-level section”)
and no file. Every published bundle is listed under ## Full-text bundles in
that language’s llms.txt, so an agent finds it in the file it already reads.
This site’s docs section publishes one: https://oink.pgsty.com/docs/llms-full.txt is the entire English documentation in one file.
Navigation JSON
The sidebar is the site’s table of contents, and an agent that can read it can
plan which pages to fetch before fetching any. The NAVJSON output publishes
that tree as navigation.json, one file per language at the language root.
Turn it on for the home page:
This produces /navigation.json and /zh/navigation.json, built from the same
tree as the sidebar and pager: the explicit data/docs_nav.json tree for a
docs or book section that has one, and the weighted content tree
elsewhere:
| Key | What it holds |
|---|---|
id |
The page path without its language prefix. The same page has the same id in every language |
url |
The absolute URL of this language’s HTML page |
markdown |
The absolute URL of the page’s .md, present only where the page publishes one |
title |
The navigation title (linkTitle, falling back to title) |
description |
The page’s description, where it has one |
kind |
home, section, or page for real pages. external or link for placeholders |
children |
The ordered children, where the node has any |
Array order is part of the contract. The theme has already applied the
sidebar order and does not serialize weight, so a consumer that sorts the
array again ends up with an order that no longer matches the sidebar.
Placeholder rows keep the sidebar’s structure. A manual_link entry becomes
an external node with the URL as written, and a manual_link_relref entry
becomes a link node with the resolved reference. Neither is a page, so
neither has an id or a markdown URL. Sidebar dividers and pages Hugo never
renders are left out, while their children stay in place.
The format is versioned: schemaVersion is 1, and the theme repository
publishes its JSON Schema as
schema/nav.v1.schema.json.
Validate the file against it if you consume it. When a language publishes
navigation.json, its llms.txt lists the file in the site index.
This site publishes it: https://oink.pgsty.com/navigation.json is the live tree.
Agent actions on the page
The page-action menu at the right end of the breadcrumb row has four entries for agents and chat assistants:
| Entry | What it does | When it appears |
|---|---|---|
| Copy Markdown | Copies this page’s .md to the clipboard. It prefetches on hover, so the copy feels instant |
This page has a markdown output |
| View markdown | Opens the .md in a new tab |
This page has a markdown output |
| Open in ChatGPT | Opens ChatGPT with a prompt about this page | assistant_links: true |
| Open in Claude | Opens Claude with a prompt about this page | assistant_links: true |
The first two come with the markdown output. Copy Markdown is also the
left half of the split button, shown as a clipboard icon that briefly turns
into a check mark after a successful copy.
The two assistant entries are off until you turn them on:
When a reader clicks one, the page builds a prompt from the full URL in the
address bar, including the real domain, query string and anchor. In English
the prompt reads “Read from
A page can narrow the site policy but not widen it. In front matter,
page_context_menu: { assistant_links: false } removes the assistant links
from that page, while true has no effect when the site has not turned them
on. page_context_menu: false removes the whole menu from a page. See
Page parameters.
Your own entries go in params.ui.page_context_menu.links. This site uses one
to add a Markdown index entry that opens llms.txt, and sets it per
language so that the label is translated:
The command palette offers the same assistant actions, from the same action list; see Command palette.
Opting a page out of .md output
Set outputs in the page’s front matter. It replaces the whole list, so name
only the formats you want to keep:
To drop only Markdown and keep a section’s feed and print view, list the rest:
Customizing the output
Most problems with these files are content problems: when llms.txt reads
badly, fix the main menu and the description fields before you touch a
template. When you do need a different shape, the theme renders the .md
output with layouts/all.md, llms.txt with layouts/index.llms.txt, and the
two optional outputs with layouts/list.llmsfull.txt and
layouts/index.navjson.json. A file of the same name under your site’s
layouts/ replaces the theme’s, but a narrower override is usually less work
to maintain:
- Per content type: a typed path such as
layouts/blog/single.mdorlayouts/docs/list.mdaffects only that kind of content, the way the theme’s own print templates specialize (layouts/blog/single.print.html). Check Hugo’s template lookup order for your combination. - Per shortcode: a site shortcode can have an output-format-specific template that gives it a more machine-readable form in Markdown.
- Per page: for a handful of important pages, writing the content by hand is cheaper than changing a template.
Replacing index.navjson.json makes you responsible for the nav.v1 format:
your output must still validate against schema/nav.v1.schema.json for
consumers that check it.
Verify
Run these from your site’s root after enabling the Markdown and LLMS outputs.
Set PAGE_MD to the generated Markdown file of a real page; the paths assume
a docs section, so adjust them and any language prefix to your site:
Against a running preview or the production site, use your own base URL and
page path. BASE_URL includes any deployment subpath and, for a translated
site, the language prefix:
Then check four things:
- The page’s HTML
<head>hasrel="alternate" type="text/markdown"; - Clicking the copy button beside the breadcrumbs and pasting gives Markdown, not HTML;
llms.txtcontains no off-site links;- If you enabled them, every page in
llms-full.txtstarts with aSource:line, and a page has the sameidin every language’snavigation.json.
Limits
- The theme produces four kinds of machine-readable file: a
.mdper page,llms.txt, and, when you enable them,llms-full.txtper top-level section andnavigation.jsonper language.sitemap.xmlremains Hugo’s own. - Bundles belong to top-level sections, and there is no whole-site
llms-full.txt. An agent that wants everything reads the section bundles thatllms.txtlists. LLMS,LLMSFULLandNAVJSONget no<head>alternate link and no page action. Agents find them at their conventional paths and throughllms.txt.- Serving Markdown from the page URL itself when a client sends
Accept: text/markdownis content negotiation, which belongs to your web server or host, not the theme. - The Markdown output is built from the source, so anything drawn only in the browser, such as a chart rendered at runtime, appears in the
.mdas its fence source, not as a picture.
Related
- Print — the other non-HTML output
- Command palette — the other entry point to the assistant actions
- Page parameters —
outputs/assistant_links/page_context_menu - Navigation and menus —
llms.txt’s site index comes from the main menu - Configuration — full definitions of
outputsandparams.ui.page_context_menu.*