# How to optimize llms.txt | Talizen API for AI | Talizen

> Learn how to organize, prioritize, and exclude pages in llms.txt with a root-level /llms.ts file.

[Talizen API](/)

[EN](/api/optimize-llms-txt.md)/ [中文](/api/optimize-llms-txt.md?lang=zh)

### Overview

- [Talizen API for AI](/api.md)

### Discoverability

- [How to optimize llms.txt](/api/optimize-llms-txt.md)

### Site configuration

- [Configure talizen.config.ts](/api/talizen-config.md)
- [Implement domain-based locale routing](/api/domain-locale-routing.md)

### Backend

- [Calling external APIs on the server and managing the cache](/api/ssr-external-api-cache.md)
- [Build site backend workflows with Func](/api/func-backend.md)
- [JSON tables: definition, reads, and queries](/api/func-json-tables.md)
- [Uploads: signed direct upload and Func-generated files](/api/func-assets-upload.md)
- [Timeouts and streaming responses](/api/func-timeout-streaming.md)
- [Integrate Alipay PC Web Payment with Func](/api/func-alipay-payment.md)

### Auth

- [Require a Verified Email to Sign Up](/api/auth-verified-registration.md)
- [Reset and Change Passwords](/api/auth-password-reset.md)
- [Sign In From a Func](/api/auth-func-login.md)
- [Query users from a Func](/api/func-user-directory.md)

### Integrations

- [Send Email and Verification Codes with Integrations](/api/func-email-integration.md)
- [Take Alipay payments with an integration](/api/func-alipay-integration.md)

### Help center

[Talizen Help](/docs/start.md)

Product guides for building sites in the editor.

DiscoverabilityHow to optimize llms.txt

# How to optimize llms.txt

Turn a flat list of URLs into a concise, prioritized map that helps AI systems find the right Talizen pages first.

Talizen automatically serves `/llms.txt` and a Markdown version of every indexed page. The URL inventory comes from the same source as the sitemap, while a root-level `/llms.ts` controls how those URLs are presented to an AI reader.

## Why structure matters

Without configuration, every page appears in one alphabetically sorted `Pages` section. That is a safe default, but it gives a pricing page, a key implementation guide, and a minor legal page equal prominence.

A better file puts high-value product and documentation pages first, groups related content, and removes pages that are duplicated, obsolete, private in intent, or too weak to help an AI answer accurately.

The title and summary need no configuration: they come from the site's `metadata.title` and `metadata.description`, so improving those updates the file automatically. A `/public/llms.txt` is never served — the platform always provides its own.

## Recommended configuration

Create `/llms.ts` at the project root and default-export a function (it may be `async`). Returning an object declares the structure and lets the platform enumerate and lay out pages. The following configuration prioritizes core pages and AI documentation, keeps the blog together, and marks legal content as optional.

```typescript
// /llms.ts
export default function llms() {
  return {
    sections: [
      { name: 'Core pages', pages: ['/', '/pricing', '/templates', '/figma-to-website'] },
      { name: 'Docs', pages: ['/docs/*'] },
      { name: 'Blog', pages: ['/blog/*'] },
      { name: 'Optional', pages: ['/solutions/*', '/contact'] },
    ],
    exclude: [
      '/cmstest',
      '/newfile',
    ],
  }
}
```

Section names are emitted exactly as written, so use labels that make sense to the AI audience for your site. The name `Optional` has special placement semantics and is conventionally used for links an AI can skip when context is limited.

## How matching works

### Exact paths

A pattern such as `/price` matches only `/price`. A leading slash may be omitted, but including it is clearer.

### Prefix wildcards

A trailing `/*` matches the prefix page and every child path. `/docs/ai/*` matches `/docs/ai` and `/docs/ai/guide`, but not `/docs/ai-tools`.

### First match wins

A page is assigned to the first matching section. Put narrow, high-priority sections before broad catch-all patterns.

### Exclusions win first

The exclude list is checked before sections. A matching page is omitted even if it also matches a section pattern.

Inside a section, the order of patterns in `pages` is the primary sort order. URLs matched by the same pattern are sorted alphabetically. Empty sections are not rendered.

Pages that match no configured section are preserved in an automatic `Pages` section. If an `Optional` section exists, this fallback section is inserted immediately before it; otherwise it appears last. Set `includeUnmatched: false` to drop those unclaimed pages instead.

To list links by hand, write a section as `{ name, links }` where each entry is `{ name, url }`. Such a section skips pattern matching and may sit in the same `sections` array as `pages` sections — hand-pick the important few, let the platform fill the rest.

## Add site context

Use `details` for a short Markdown briefing that should be available before an AI follows any page link. Keep it factual, stable, and compact: what the product is, which documentation is authoritative, and any important terminology.

```typescript
return {
  details: `Talizen is a visual and AI website builder.
Use the AI website docs for implementation guidance.
Use core pages for product and pricing facts.`,
  sections: [/* ... */],
}
```

The generated file already starts with the site title and `metadata.description`. Do not repeat those verbatim in `details`; use the space for context that improves routing and interpretation.

## Take full control

Return a string instead of an object and it becomes the entire `/llms.txt` — you own the heading, the summary, and every link. The `ctx` argument still hands you the platform's page enumeration, so you are not starting from nothing.

```typescript
export default function llms(ctx) {
  const docs = ctx.pages.filter((p) => p.path.startsWith('/docs/'))
  return [
    `# ${ctx.metadata.title}`,
    '',
    '## Docs',
    '',
    ...docs.map((p) => `- [${p.path}](${p.url})`),
    '',
  ].join('\n')
}
```

`ctx` provides `origin`, `pages` (each with `path`, `url`, and an optional `lastModified`), and `metadata`. See `LLMsFile` and `LLMsContext` in the talizen package for the full types.

## Verification checklist

- Open `/llms.txt` on the deployed domain and confirm the most important section appears first.
- Follow several generated `.md` links, including `/index.md` for the home page, and verify the content is useful without browser-only UI.
- Check that wildcard patterns do not unintentionally absorb a more specific section.
- Confirm excluded URLs are absent and unclassified pages still appear under `Pages`.
- Keep `Optional` last so constrained AI readers can safely deprioritize it.
- If `/llms.ts` throws or returns the wrong shape, the endpoint returns 5xx rather than quietly falling back to the default output — a 5xx there means the file itself has a bug.

**Result**

A strong `llms.txt` is intentionally smaller in cognitive load, not necessarily smaller in page count. Give AI systems a clear path from product facts to implementation guidance, then move low-priority material out of the way.

[Previous\
\
Talizen API for AI](/api.md) [Next\
\
Configure talizen.config.ts](/api/talizen-config.md)

On this page

- [Why structure matters](#why-structure-matters)
- [Recommended configuration](#recommended-configuration)
- [How matching works](#how-matching-works)
- [Exact paths](#exact-paths)
- [Prefix wildcards](#prefix-wildcards)
- [First match wins](#first-match-wins)
- [Exclusions win first](#exclusions-win-first)
- [Add site context](#add-site-context)
- [Take full control](#full-control)
- [Verification checklist](#verification-checklist)

Looking for the help center?

[Talizen Help](/docs/start.md)

> 全站页面清单：[/llms.txt](/llms.txt)
