Llms.txt是什么?2026年AI高效读取网站内容协议详解
Llms.txt is an open standard protocol that provides AI with a structured, Markdown-based 'map' and 'manual' for websites, enabling efficient content retrieval and reducing AI processing costs by eliminating HTML/CSS/JS noise.
原文翻译: Llms.txt是一个开放标准协议,为AI提供基于Markdown的结构化网站“地图”和“说明书”,实现高效内容检索,并通过消除HTML/CSS/JS噪音降低AI处理成本。
When AI stops “looking” at web pages and starts “reading” documents, is your website ready to converse with AI?
当AI不再“看”网页,而是“读”文档,你的网站准备好和AI对话了吗?
引言:重新定义AI与网站的交互
在开始测评前,我们需要先明确一个概念:Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 Documentation 本身并不是一个大语言模型(LLM),也不是一个需要“运行”的软件。它更像是一个开放的标准协议,或者说是一份写给AI看的“网站地图”和“精简版说明书”。
Before we begin the evaluation, it's crucial to clarify a concept: Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 Documentation is not a Large Language Model (LLM) itself, nor is it a piece of software that needs to be "run." It is more akin to an open standard protocol, or a "site map" and "condensed manual" written for AI.
它存在的意义,就是解决目前AI在读取我们传统网站时“眼花缭乱、抓不住重点”的痛点。想象一下,让AI去看一个充满广告、导航栏、动态特效的普通网页,它就像在嘈杂的集市里找人,效率极低且容易出错。而 Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 提供了一个静谧、整洁的“会议室”,让AI能直截了当地获取核心信息。
Its purpose is to address the current pain point where AI struggles with "information overload and difficulty grasping key points" when reading traditional websites. Imagine asking an AI to parse a typical webpage filled with ads, navigation bars, and dynamic effects—it's like trying to find someone in a noisy marketplace: inefficient and error-prone. Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 provides a quiet, clean "meeting room" where AI can directly access the core information.
1. 模型概述:不是“模型”的“模型”
虽然它不是传统意义上的模型,但我们可以将其视为一个**“AI上下文增强协议”**。
Although it is not a model in the traditional sense, we can think of it as an "AI Context Enhancement Protocol."
1.1 能力评估:它具体能做什么?
它的核心能力不是“推理”,而是**“结构化呈现与导航”**。具体能完成以下任务:
Its core capability is not "reasoning," but "structured presentation and navigation." Specifically, it can accomplish the following tasks:
- 文档索引:提供一个
/llms.txt文件,作为网站的“目录”,告诉AI哪里有最重要的内容。Document Indexing: Provides an
/llms.txtfile that acts as a website's "table of contents," informing the AI where the most important content resides. - 内容聚合:提供一个
/llms-full.txt文件,将整个文档库“压缩”成一个巨大的MarkdownA lightweight markup language for creating formatted text using a plain-text editor.文件,方便AI一次性读完所有资料。Content Aggregation: Provides an
/llms-full.txtfile that "compresses" the entire documentation library into one large MarkdownA lightweight markup language for creating formatted text using a plain-text editor. file, allowing the AI to read all materials at once. - 按需获取:支持通过URL后缀
.md的方式,直接获取当前页面的纯净MarkdownA lightweight markup language for creating formatted text using a plain-text editor.版本。On-Demand Retrieval: Supports fetching the clean MarkdownA lightweight markup language for creating formatted text using a plain-text editor. version of any page by appending
.mdto its URL.
有多少个接口?
How Many Endpoints Are There?
严格来说,它本身不提供API接口,而是定义了三个标准的“端点”:
Strictly speaking, it does not provide API interfaces itself but defines three standard "endpoints":
https://yourdomain.com/llms.txt:轻量级索引。https://yourdomain.com/llms.txt: Lightweight index.https://yourdomain.com/llms-full.txt:完整内容导出。https://yourdomain.com/llms-full.txt: Full content export.https://yourdomain.com/any/page.md:单个页面的MarkdownA lightweight markup language for creating formatted text using a plain-text editor.版本。https://yourdomain.com/any/page.md: MarkdownA lightweight markup language for creating formatted text using a plain-text editor. version of a single page.
1.2 技术特点介绍:给AI吃的“营养餐”
- 极简主义:完全采用MarkdownA lightweight markup language for creating formatted text using a plain-text editor.格式,彻底剥离HTML、CSS和JavaScript,让AI的上下文窗口100%用于理解内容,而不是过滤垃圾信息。
Minimalism: Uses pure MarkdownA lightweight markup language for creating formatted text using a plain-text editor. format, completely stripping away HTML, CSS, and JavaScript. This ensures the AI's context window is 100% dedicated to understanding content, not filtering out noise.
- 双模策略:通过
llms.txt(索引)和llms-full.txt(全文)的配合,兼顾了轻量级查询和深度阅读的需求。这就好比给AI一本“字典目录”和一本“百科全书”,按需使用。Dual-Mode Strategy: The combination of
llms.txt(index) andllms-full.txt(full text) caters to both lightweight queries and deep reading needs. It's like providing the AI with both a "dictionary index" and an "encyclopedia" to use as needed. - 人类与机器双友好:MarkdownA lightweight markup language for creating formatted text using a plain-text editor.本身易读易写,开发者可以轻松维护,AI也能轻松解析。
Human and Machine Friendly: MarkdownA lightweight markup language for creating formatted text using a plain-text editor. is inherently easy to read and write, allowing developers to maintain it effortlessly while also being easily parsed by AI.
1.3 应用场景:谁最需要它?
- 技术文档型网站:如API文档应用程序编程接口文档,描述软件组件如何交互,是Llms.txt的主要应用场景之一。、SDK指南(例如 Stripe、Vercel 的文档)。让Cursor、Copilot等编程助手能精准根据你的API生成代码。
Technical Documentation Websites: Such as API documentation, SDK guides (e.g., Stripe, Vercel docs). Enables programming assistants like Cursor and Copilot to generate code accurately based on your APIs.
- 企业内部知识库:让企业内部的AI客服或员工助手,能准确基于最新的内部Wiki回答问题,而不是基于过时的训练数据。
Internal Enterprise Knowledge Bases: Allows internal AI customer service or employee assistants to answer questions based on the latest internal Wiki, rather than outdated training data.
- 开源项目主页:让想了解项目的AI助手(如ChatGPT with Bing)能快速抓取项目核心定位,向用户提供准确的摘要。
Open-Source Project Homepages: Enables AI assistants (like ChatGPT with Bing) that want to understand a project to quickly grasp its core purpose and provide accurate summaries to users.
2. 安装与部署方式:把说明书放到AI能拿到的地方
部署 Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 并不需要复杂的编程,主要是将文件放置到正确的位置。我们分场景来看:
Deploying Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 doesn't require complex programming; it's primarily about placing files in the correct location. Let's examine different scenarios:
方案 A:懒人包方案——使用自动化工具(如 GitBook, Apifox)
这是目前最简单的方式,适合所有操作系统(Windows/macOS/Linux)。
This is currently the simplest method, suitable for all operating systems (Windows/macOS/Linux).
- 准备工作:拥有一个基于 GitBook 或 Apifox 发布的在线文档站点。
Prerequisites: Have an online documentation site published using GitBook or Apifox.
- 操作步骤:
Steps:
- Apifox:进入项目 -> “分享文档” -> 发布文档站 -> 在“AI相关特性”中,确保 Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 功能开启(默认开启)。系统会自动生成
llms.txt和所有页面的.md版本。Apifox: Go to Project -> "Share Docs" -> Publish Doc Site -> Under "AI Features," ensure the Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 function is enabled (enabled by default). The system will automatically generate
llms.txtand.mdversions of all pages. - GitBook:在你发布文档站的那一刻,GitBook 就已经自动在根目录生成了
llms.txt和llms-full.txt。GitBook: The moment you publish your documentation site, GitBook automatically generates
llms.txtandllms-full.txtin the root directory.
- Apifox:进入项目 -> “分享文档” -> 发布文档站 -> 在“AI相关特性”中,确保 Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 功能开启(默认开启)。系统会自动生成
- 验证:在浏览器中访问
https://你的文档域名/llms.txt,如果能看到一个结构清晰的MarkdownA lightweight markup language for creating formatted text using a plain-text editor.文件列表,即成功。Verification: Visit
https://your-doc-domain/llms.txtin your browser. If you see a well-structured MarkdownA lightweight markup language for creating formatted text using a plain-text editor. file list, you have succeeded.
方案 B:手动挡方案——手动创建并上传(全系统适用)
如果你是自己托管的静态网站(如使用 Hugo, VuePress 等)。
If you are self-hosting a static website (e.g., using Hugo, VuePress).
- 准备工作:
Prerequisites:
- 一台电脑 + 一个文本编辑器(如 VSCode, Notepad++)。
A computer + a text editor (e.g., VSCode, Notepad++).
- 具备你的网站服务器(如 Nginx, Apache, GitHub Pages)的文件上传权限。
Have file upload permissions for your web server (e.g., Nginx, Apache, GitHub Pages).
- 一台电脑 + 一个文本编辑器(如 VSCode, Notepad++)。
- 步骤(以macOS/Linux为例,Windows类似):
Steps (using macOS/Linux as an example, similar for Windows):
- 创建文件:在本地创建一个名为
llms.txt的文本文件。Create File: Create a text file named
llms.txtlocally. - 编写内容:打开文件,按照以下模板编写:
Write Content: Open the file and write according to the following template:
# 你的项目/公司名 > 用一句话简单描述你的项目是做什么的。 ## 入门指南 - [快速开始](https://yourdomain.com/docs/quickstart.md): 5分钟上手教程 - [安装指南](https://yourdomain.com/docs/installation.md): 详细的安装步骤 ## 核心API - [用户认证](https://yourdomain.com/api/auth.md): 登录、注册、Token刷新 - [数据操作](https://yourdomain.com/api/data.md): 增删改查接口说明 ## 资源 - [常见问题](https://yourdomain.com/help/faq.md) - [更新日志](https://yourdomain.com/changelog.md) - 生成MarkdownA lightweight markup language for creating formatted text using a plain-text editor.页面:你需要确保链接指向的
.md文件真实存在。大多数静态站点生成器都可以配置同时输出.html和.md版本,或者你可以复制你的文档内容另存为.md文件。Generate MarkdownA lightweight markup language for creating formatted text using a plain-text editor. Pages: You need to ensure the
.mdfiles linked to actually exist. Most static site generators can be configured to output both.htmland.mdversions, or you can copy your document content and save it as.mdfiles. - 上传部署:将
llms.txt文件和你所有的.md文件上传到你网站的根目录或相应路径下。Upload and Deploy: Upload the
llms.txtfile and all your.mdfiles to the root directory or corresponding paths of your website. - Windows用户注意:确保文件扩展名是
.txt而不是.txt.txt。可以在文件夹选项中开启“显示文件扩展名”来检查。Note for Windows Users: Ensure the file extension is
.txtand not.txt.txt. You can check this by enabling "Show file extensions" in Folder Options.
- 创建文件:在本地创建一个名为
方案 C:极客方案——通过 MCP 服务器动态提供(开发环境)
这种方式主要面向 Cursor、Claude Code 这类深度集成的IDE,让AI在编码时能实时“查阅”文档。
This method is primarily aimed at deeply integrated IDEs like Cursor and Claude Code, allowing AI to "consult" documentation in real-time while coding.
- 前提:系统已安装 Node.js 和 Python 环境。
Prerequisite: Node.js and Python environments are installed on the system.
- 配置(以 Cursor 为例,适用 Windows/macOS/Linux):
Configuration (using Cursor as an example, applicable to Windows/macOS/Linux):
- 在项目根目录下创建或编辑
.cursor/mcp.json文件。Create or edit the
.cursor/mcp.jsonfile in the project root directory. - 填入以下配置,告诉 Cursor 去启动一个 MCP 文档服务器:
Fill in the following configuration to instruct Cursor to start an MCP documentation server:
{ "mcpServers": { "my-docs": { "command": "uvx", "args": [ "--from", "mcpdoc", "mcpdoc", "--urls", "MyProject:https://yourdomain.com/llms.txt", "--transport", "stdio" ] } } } - 重启 Cursor,AI 助手现在就能通过 MCP 工具调用你的文档了。
Restart Cursor. The AI assistant can now access your documentation via the MCP tool.
- 在项目根目录下创建或编辑
常见问题与修复
- 问题:AI 说无法访问我的
llms.txt文件。Issue: The AI reports it cannot access my
llms.txtfile.- 解决:检查文件是否放在了根目录,并且服务器权限设置为允许公开访问。可以用
curl -I https://你的域名/llms.txt命令查看HTTP头信息,确认返回200 OK。Solution: Check if the file is placed in the root directory and if server permissions allow public access. You can use the command
curl -I https://yourdomain.com/llms.txtto view HTTP headers and confirm a200 OKresponse.
- 解决:检查文件是否放在了根目录,并且服务器权限设置为允许公开访问。可以用
- 问题:文件太大了,AI 说超出长度(针对
llms-full.txt)。Issue: The file is too large; the AI reports exceeding the length limit (for
llms-full.txt).- 解决:改用
llms.txt索引模式,让AI先看目录,再按需去读具体的.md文件。Solution: Switch to the
llms.txtindex mode. Let the AI view the directory first, then read specific.mdfiles as needed.
- 解决:改用
3. 配套客户端:谁来读这份说明书?
Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 是一个标准,几乎所有主流AI工具都能读取。
Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 is a standard that can be read by almost all mainstream AI tools.
| 客户端名称 | 是否付费 | 配置方式/使用方式 | 下载地址 |
|---|---|---|---|
| Cursor | 付费/免费试用 | MCP集成:配置mcp.json @Docs:直接在输入框输入@Docs引用llms.txtURL |
cursor.com |
| Windsurf | 付费/免费试用 | 规则文件:在.windsurfrules中添加文档URL,或使用@引用 |
codeium.com |
| Claude Code | 免费(测试版) | 命令行配置:通过claude mcp add命令添加 MCP 服务器 |
anthropic.com |
| ChatGPT | 免费/付费Plus | Web Browsing:开启联网搜索后,直接粘贴llms.txt或.md文件的URL |
chat.openai.com |
| Apifox | 免费基础版 | 内置功能:无需配置,发布文档时自动生成 | apifox.com |
| GitHub Copilot | 付费 | 间接使用:不支持直接读URL,需将文档片段作为注释或提示词的一部分 | github.com |
Client Name Paid/Free Configuration/Usage Download Link Cursor Paid/Free Trial MCP Integration: Configure mcp.json@Docs: Directly type@Docsfollowed by thellms.txtURL in the input boxcursor.com Windsurf Paid/Free Trial Rule File: Add doc URL in .windsurfrules, or use@referencecodeium.com Claude Code Free (Beta) CLI Configuration: Add MCP server via claude mcp addcommandanthropic.com ChatGPT Free/Plus Web Browsing: After enabling web search, directly paste the llms.txtor.mdfile URLchat.openai.com Apifox Free Basic Built-in Feature: No configuration needed, automatically generated when publishing docs apifox.com GitHub Copilot Paid Indirect Use: Does not support reading URLs directly; requires using document snippets as part of comments or prompts github.com
4. 案例讲解:手把手教你打造一个“AI友好”的宠物商店API
假设我们有一个**“喵星人宠物商店”API**,想让AI(比如Cursor)能准确理解我们的接口,帮前端同事自动生成TypeScript的调用代码。
Suppose we have a "Meow Star Pet Store" API and want AI (e.g., Cursor) to accurately understand our interfaces and help frontend colleagues automatically generate TypeScript calling code.
模拟场景
后端开发者小王写好了API文档应用程序编程接口文档,描述软件组件如何交互,是Llms.txt的主要应用场景之一。,但前端小张每次都要手动翻看复杂的HTML文档来写请求代码,很耗时。小王决定采用 Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 标准,让AI助手变成他们的“API传话筒”。
Backend developer Xiao Wang has written the API documentation, but frontend developer Xiao Zhang spends a lot of time manually browsing complex HTML documents to write request code. Xiao Wang decides to adopt the Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。 standard, turning the AI assistant into their "API interpreter."
实施步骤
- 准备文档:小王使用 Ap
常见问题(FAQ)
Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。是什么?它和普通网站地图有什么区别?
Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。是一个开放标准协议,为AI提供基于MarkdownA lightweight markup language for creating formatted text using a plain-text editor.的结构化网站“地图”和“说明书”。它通过纯MarkdownA lightweight markup language for creating formatted text using a plain-text editor.格式消除HTML/CSS/JS噪音,让AI能高效获取核心内容,而传统网站地图主要为人类设计且包含大量无关元素。
如何为我的网站部署Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。?有哪些具体方法?
主要有两种部署方式:方案A是使用GitBook、Apifox等自动化工具生成;方案B是手动创建并上传llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。和llms-full.txt文件到网站根目录。核心是让AI能通过标准端点访问这些MarkdownA lightweight markup language for creating formatted text using a plain-text editor.格式的“说明书”。
Llms.txt一个开放标准协议,为AI提供结构化、Markdown格式的网站内容索引和导航,解决AI读取传统网页时效率低下的问题。对哪些类型的网站最有价值?
技术文档型网站(如API文档应用程序编程接口文档,描述软件组件如何交互,是Llms.txt的主要应用场景之一。、SDK指南)最需要它。它能让Cursor、Copilot等编程助手精准理解API内容并生成代码,同时适用于任何希望与AI高效交互、降低AI处理成本的网站。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。