Generate llms.txt in Astro

An llms.txt file gives agents a concise map of machine-readable pages. It does not replace a sitemap, robots policy, or good documentation. It complements them by pointing directly to useful Markdown representations.

The Markdown for Agents integration generates llms.txt during astro build.

Basic configuration

pnpm add @puralex/astro-markdown-for-agents
import { defineConfig } from 'astro/config';
import markdownForAgents from '@puralex/astro-markdown-for-agents';

export default defineConfig({
  integrations: [
    markdownForAgents({
      siteTitle: 'Acme API Documentation',
      siteDescription: 'API guides, references, and deployment documentation.',
    }),
  ],
});

Build your site:

pnpm astro build

Generated output resembles:

# Acme API Documentation
> API guides, references, and deployment documentation.

## Pages
- [/](./index.md)
- [docs/](/docs/index.md)
- [api/authentication/](/api/authentication/index.md)

The integration respects Astro’s configured base path, which matters for GitHub Pages and subdirectory deployments.

Disable generation

If another tool owns llms.txt, disable this feature:

markdownForAgents({
  generateLlmsTxt: false,
});

What should appear in llms.txt?

Include pages that help an agent answer questions or perform tasks:

Exclude low-value or sensitive surfaces:

Current generation follows built Astro pages. Review the file during CI before publishing.

After deployment:

curl -fsS https://example.com/llms.txt
curl -fsS https://example.com/docs/index.md

For a site deployed below a base path:

curl -fsS https://example.github.io/project/llms.txt

Automate link validation in CI if documentation routes change frequently.

Discovery beyond llms.txt

Also consider:

llms.txt improves discovery. Clean, accurate content determines usefulness.