# How to generate llms.txt for your website - agentmarkup

> Learn how to auto-generate a spec-compliant llms.txt file at build time using agentmarkup with Vite, Astro, or Next.js. Follow the llmstxt.org standard to make your site discoverable by LLMs and AI agents.

Source: https://agentmarkup.dev/docs/llms-txt/

# How to generate llms.txt for your website

llms.txt is a proposed standard from [llmstxt.org](https://llmstxt.org) that gives LLMs and AI agents a structured overview of your website. It is a plain text file served at `/llms.txt` that describes your site name, purpose, and pages in a format optimized for language models.

## What is llms.txt?

When an LLM or AI assistant visits your website, it needs to understand what your site is about, what pages exist, and what content is available. HTML pages are designed for humans. llms.txt is designed for machines.

The format is simple markdown: an H1 heading with your site name, an optional blockquote description, optional instructions, and H2 sections grouping page links with short descriptions.

## Why generate llms.txt at build time?

Manually maintaining an llms.txt file means keeping it in sync with your actual pages, remembering the correct markdown format, and resolving relative URLs to absolute ones. agentmarkup handles all of this automatically during your build.

- Your llms.txt is always in sync with your site configuration
- Relative URLs are automatically resolved to absolute URLs
- The output follows the llmstxt.org spec exactly
- Build-time validation catches formatting errors before you deploy

## Configuration

The `llmsTxt` config itself is shared across the first-party adapters. Define sections and entries that describe the pages on your site once, then pass the same config into Vite, Astro, or Next.js.

```
// shared agentmarkup config
const agentmarkupConfig = {
 site: 'https://example.com',
 name: 'My Website',
 description: 'A short description of your website.',
 llmsTxt: {
 instructions: 'Optional instructions for LLMs visiting this site.',
 sections: [
 {
 title: 'Pages',
 entries: [
 { title: 'About', url: '/about', description: 'About us' },
 { title: 'Blog', url: '/blog', description: 'Latest posts' },
 ],
 },
 ],
 },
 llmsFullTxt: {
 enabled: true,
 },
 markdownPages: {
 enabled: true,
 },
}
```

## Framework wrappers

Once you have the shared config object, wire it into the adapter that owns your final build output:

```
// Vite
import { defineConfig } from 'vite'
import { agentmarkup } from '@agentmarkup/vite'

export default defineConfig({
 plugins: [agentmarkup(agentmarkupConfig)],
})

// Astro
import { defineConfig } from 'astro/config'
import { agentmarkup } from '@agentmarkup/astro'

export default defineConfig({
 integrations: [agentmarkup(agentmarkupConfig)],
})

// Next.js
import type { NextConfig } from 'next'
import { withAgentmarkup } from '@agentmarkup/next'

const nextConfig: NextConfig = {
 output: 'export',
}

export default withAgentmarkup(agentmarkupConfig, nextConfig)
```

## Generated output

The plugin outputs a spec-compliant `/llms.txt` file in your build directory:

```
# My Website

> A short description of your website.

Optional instructions for LLMs visiting this site.

## Pages

- [About](https://example.com/about.md): About us
- [Blog](https://example.com/blog.md): Latest posts
```

With markdown mirrors enabled in the example above, same-site page entries in `llms.txt` default to the generated `.md` URLs so cold agents discover the cleaner fetch path first. Set `llmsTxt.preferMarkdownMirrors` to `false` if your raw HTML is already substantial and you want `llms.txt` to keep pointing at HTML routes.

## Optional llms-full.txt

If you enable `llmsFullTxt`, agentmarkup also emits an optional `/llms-full.txt` file. It keeps the same high-level manifest structure as `llms.txt` but inlines same-site markdown mirror content when those mirrors exist, which gives agents a richer machine-readable context file without making you hand-maintain a second document.

```
# My Website

> A short description of your website.

Optional instructions for LLMs visiting this site.

This optional agentmarkup context file expands the published llms.txt manifest with inline same-site markdown content when those mirrors are available.

## Pages

- [About](https://example.com/about.md): About us
- [Blog](https://example.com/blog.md): Latest posts

### About

> About us

Source: https://example.com/about
Preferred fetch: https://example.com/about.md

About the company, team, and public positioning...
```

## Validation

agentmarkup validates your `llms.txt` and `llms-full.txt` output at build time. It checks that the files start with an H1 heading, have at least one section, and that all links have valid titles and URLs. If markdown mirrors are enabled, it also warns when `llms.txt` points to a markdown URL that was never emitted.

## LLM discovery

agentmarkup injects the homepage `llms.txt` discovery link automatically when you generate or ship an `llms.txt` file. The tag looks like this:

```
<link rel="alternate" type="text/plain" href="/llms.txt" title="LLM-readable site summary" />
```

Combined with a proper [robots.txt configuration](/docs/ai-crawlers/) that allows AI crawlers, this makes your site discoverable and understandable by AI agents.

## Frequently asked questions

 Do AI models actually read llms.txt?

Some AI systems like Perplexity have started checking for llms.txt. The format is still early, but the cost of generating it is near zero and it provides a clean machine-readable overview of your site.

 Can I have both llms.txt and llms-full.txt?

Yes. llms.txt is the summary. llms-full.txt is optional expanded context. agentmarkup can generate both, and when markdown mirrors are enabled it inlines the same-site mirror content into llms-full.txt automatically.

 What happens if I do not configure llmsTxt?

No llms.txt file is generated. The other features (JSON-LD, markdown mirrors, robots.txt, optional headers, and validation) still work independently. You can enable features selectively.
