---
title: "llms.txt"
description: "文档站自动生成 /llms.txt 与 /llms-full.txt，为大语言模型提供站点目录与全文。本页说明默认值从哪里来、如何配置标题与分组、它们与每页 Markdown 表示的关系，以及在 Cursor 等工具中的用法。"
canonical_url: "https://docs.mhaibaraai.cn/docs/ai/llms-txt"
---
# llms.txt

> 文档站自动生成 /llms.txt 与 /llms-full.txt，为大语言模型提供站点目录与全文。本页说明默认值从哪里来、如何配置标题与分组、它们与每页 Markdown 表示的关系，以及在 Cursor 等工具中的用法。

[llms.txt](https://llmstxt.org) 是面向大语言模型的站点索引约定。Movk Nuxt Docs 集成 [`nuxt-llms`](https://github.com/nuxt-content/nuxt-llms)，构建时预渲染两个文件：

| 文件 | 内容 | 适用场景 |
| --- | --- | --- |
| `/llms.txt` | 站点标题、简介与页面链接，链接指向每页的 Markdown 表示 | 让模型先了解文档有哪些内容 |
| `/llms-full.txt` | 全部文档的 Markdown 全文 | 一次性把整站内容交给支持长上下文的工具 |

> [!NOTE]
> See: https://docs.mhaibaraai.cn/llms.txt
> 
> 查看本站生成的 
> 
> /llms.txt

## 默认值

不做任何配置时，layer 按以下来源填充：

| 选项 | 来源 |
| --- | --- |
| `llms.domain` | 环境变量 `NUXT_PUBLIC_SITE_URL`、`NUXT_SITE_URL`，或部署平台提供的地址（Vercel、Netlify、Cloudflare Pages、GitLab Pages），都没有时为 `https://example.com` |
| `llms.title` / `llms.full.title` | `site.name`，其次为 `package.json` 的 `name` |
| `llms.description` / `llms.full.description` | `package.json` 的 `description` |

`domain` 决定文件中所有链接的前缀，生产构建前务必确认它是正式地址。

## 配置

在 `nuxt.config.ts` 的 `llms` 中覆盖：

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  llms: {
    domain: 'https://docs.example.com',
    title: 'My Library',
    description: 'My Library 的官方文档，涵盖安装、配置与 API。',
    notes: [
      '所有页面都可以在 URL 后加 .md 获取 Markdown'
    ],
    full: {
      title: 'My Library 完整文档',
      description: '全部文档页面的 Markdown 全文。'
    }
  }
})
```

- `notes` 渲染为文件末尾的 `## Notes` 列表
- 设置 `full` 后才生成 `/llms-full.txt`，layer 默认已设置

### 页面分组

页面链接由 [`nuxt-agent-discovery`](https://docs.mhaibaraai.cn/docs/ai/agent-discovery) 从内容集合中读取，链接自动改写为对应的 `/raw/**.md` 地址，与读者访问 `.md` 时拿到的内容一致。需要自定义分组时，用 `llms.sections` 按集合与路径筛选：

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  llms: {
    sections: [
      {
        title: 'Getting Started',
        contentCollection: 'docs',
        contentFilters: [
          { field: 'path', operator: 'LIKE', value: '/docs/getting-started%' }
        ]
      },
      {
        title: 'Guide',
        contentCollection: 'docs',
        contentFilters: [
          { field: 'path', operator: 'LIKE', value: '/docs/guide/%' }
        ]
      }
    ]
  }
})
```

自带 `links` 的分组原样保留，其中指向站内页面的链接同样会改写为 Markdown 地址。

### 补充说明

`agentDiscovery.llms.details` 在简介与第一个分组之间插入说明段落，适合告诉模型如何使用这些文件。需要同时设置 `llms.description`，且段落中不能包含标题：

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  agentDiscovery: {
    llms: {
      details: [
        '每个页面在 URL 后加 `.md` 即可获取 Markdown。',
        '需要整站内容时读取 `llms-full.txt`。'
      ]
    }
  }
})
```

### 多语言

`nuxt-llms` 每个站点只生成一份 `/llms.txt`，标题与简介不区分语言。多语言站点建议用面向模型的语言撰写 `llms.description`，并在 `details` 中说明其他语言的路径前缀（如 `/en/docs`）。

## 与 Markdown 表示的关系

`llms.txt` 只是入口。每个页面都有自己的 Markdown 表示，由[代理发现](https://docs.mhaibaraai.cn/docs/ai/agent-discovery)提供：

```bash [Terminal]
# 在页面 URL 后加 .md
curl https://docs.example.com/docs/getting-started.md

# 或直接访问 raw 路径
curl https://docs.example.com/raw/docs/getting-started.md
```

MDC 组件在输出前转换为纯 Markdown，模型拿到的是可直接阅读的文本。

## 在 AI 工具中使用

- **Cursor**：在对话中输入 `@Docs`，添加 `https://docs.example.com/llms.txt` 作为文档源（`@` 需要手动输入，粘贴不会触发）
- **Windsurf**：用 `@docs` 引用 `llms.txt` 地址，或在工作区规则中写入该地址
- **ChatGPT、Claude 等**：在提问时附上地址，例如「参考 [https://docs.example.com/llms.txt](https://docs.example.com/llms.txt) 回答」

一般先给 `/llms.txt`，模型会按需读取具体页面；只有在工具支持很长的上下文、又需要一次读完全部内容时再使用 `/llms-full.txt`。需要模型持续查询文档时，接入 [MCP Server](https://docs.mhaibaraai.cn/docs/ai/mcp) 效果更好。


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.cn/sitemap.md) for all pages.
