This plugin implements the llms.txt standard, providing markdown versions of pages and an llms.txt sitemap for agents to use. It is designed to work on any static hosting service, so it does not rely on responding with Link headers or an Accepts: text/markdown in the request.
It works by converting the rendered HTML to Markdown, instead of republishing the source markdown/MDX. This helps with any custom components or non-Markdown pages. As long as the HTML produced by a .astro is accessible, it should produce reasonable markdown.
The plugin will:
- Build a
.mdversion of every page - Include the View as Markdown footer link, for humans to easily grab & feed into an agent
- Include a
<link rel="alternate" type="text/markdown">in the page's<head>to indicate to agents looking at the HTML that there is a better format available for them - Generates a
/llms.txtindex with basic guidance and a site map.
pnpm add @nu-appdev/starlight-agent-docsImport the plugin in astro.config.mjs and add it to Starlight's plugins:
- Ensure the
sitesetting is configured. This is the base URL that will be used in/llms.txt - Register
starlightAgentDocs()after any theme or plugin that overridesEditLink
// astro.config.mjs
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import starlightAgentDocs from '@nu-appdev/starlight-agent-docs';
export default defineConfig({
site: 'https://docs.example.com',
integrations: [
starlight({
title: 'Example Docs',
description: 'Documentation for Example.',
sidebar: [
{ label: 'Guides', items: [{ autogenerate: { directory: 'guides' } }] },
{ label: 'Reference', items: [{ autogenerate: { directory: 'reference' } }] },
],
plugins: [
starlightAgentDocs({
guidance: 'Start with the guides before reading the reference.',
}),
],
}),
],
});All plugin settings are optional. Sections in /llms.txt come from Starlight's
resolved sidebar, so there is no separate section configuration to maintain.
Each top-level sidebar group becomes an H2 section, using its label and order.
Nested groups are flattened into that section, and pages follow sidebar order.
Manual and autogenerated entries are both supported.
Published pages outside those groups (including standalone top-level links and
pages hidden from the sidebar) appear under fallbackSection, sorted by HTML
URL. External links are not included, empty sections are omitted, and a page
linked more than once is listed only in its first matching group. Without
sidebar groups, all pages appear in the fallback section. Sidebar membership
does not control which pages get Markdown exports.
| Option | Type | Default | Purpose |
|---|---|---|---|
title |
string |
Starlight's title; the first configured value if localized |
Project name in the index's H1 heading. |
summary |
string |
Starlight's description, if set |
Short site summary rendered as a blockquote below the title. An empty string omits it. |
guidance |
string |
Omitted | Markdown guidance before the file lists. Paragraphs and lists are allowed, but Markdown headings are not. |
fallbackSection |
string |
'Other documentation' |
Section for published pages outside the sidebar groups. |
See CONTRIBUTING.md for development and testing.