博客加一套.md双通道,AI代理不再啃HTML
导语:Jake Marsh 用一晚给静态博客做了「每页一份 .md + Accept 内容协商 + llms.txt 索引」三件套,代理拿到的从 30KB 模板壳变成 5.6KB 纯正文。
背景:来读博客的,一半不是人
deallocatedobjects.com 是 Jake Marsh 的个人技术博客,写 iOS/Mac 开发、Objective-C、Xcode、WWDC,文章从 2010 年一直写到今天。站点是 nginx 托的静态站,没有 CMS,没有插件市场。
他的判断很直接:来取页面的「读者」里,有相当一部分是 Claude、ChatGPT、Perplexity 这类代理,替某个正在提问的人先来读一遍。HTML 对它们不友好——导航、脚本、样式、埋点、模板壳子占了大半体积,真正的内容被埋在里面;代理要么多花 token 解析,要么解析错、抓错段落,最后把一段代码写成了另一个版本。
2026 年 10 月 24 日他把改造过程写了出来(原文:《Making My Blog Readable By AI Agents》)。核心不是"再发一份内容",而是同一份 Markdown 源,同时产出 HTML 和 .md 两种形态,谁也不会漂移。
落地清单
1. 文件位置与路由
| 路径 | 作用 | 本机实测(2026-12-06) |
|---|---|---|
/llms.txt | 代理导览:站点是什么、怎么取文、怎么引用、栏目与文章清单 | 200,text/plain; charset=utf-8,43,888 字节,215 行 |
/llms-full.txt | 全站正文合订本 | 200,text/plain,656,662 字节,9,128 行 |
/index.md | 首页的 Markdown 孪生,列出全部文章 | 与 .md 规则一致 |
/posts/<slug>.md | 每篇文章的 Markdown 版,带 YAML frontmatter | 200,text/markdown,5,657 字节 |
/posts/<slug>.json | 单篇元数据(html_url / source_url) | 供程序化消费 |
/search.json、/feed.json | 全站搜索索引、JSON Feed(每条含 _markdown_url) | 给不想翻页的代理 |
关键点:.md 不是另一份内容,是构建产物。正文只维护 Markdown 一份,HTML 和 .md 都从它生成——这是"不漂移"的前提。
2. llms.txt 原文片段(真实截取,2026-12-06 抓取)
# Deallocated Objects
Jake Marsh's blog about iOS and Mac development (Objective-C, open source libraries, Xcode, WWDC), design, Apple, AI agents and the software industry. Posts from 2010 to today.
## Markdown for agents
- Every post is available as clean Markdown: add `.md` to the post URL, e.g. https://deallocatedobjects.com/posts/mew-is-finally-under-the-truck.md
- Or request the normal post URL with `Accept: text/markdown` and the server returns Markdown instead of HTML (responses send `Vary: Accept`).
- Every other page has a Markdown twin too: add `.md` to its URL (https://deallocatedobjects.com/about.md, https://deallocatedobjects.com/archive.md, https://deallocatedobjects.com/topics.md) or send `Accept: text/markdown`.
- https://deallocatedobjects.com/index.md lists every post. https://deallocatedobjects.com/llms-full.txt has the full text of every post in one file.
- https://deallocatedobjects.com/search.json is a search index (title, URL, date, topics, summary, text) of every post.
## Feeds
- Atom: https://deallocatedobjects.com/feed
- JSON Feed: https://deallocatedobjects.com/feed.json (items include a `_markdown_url`)
- Sitemap: https://deallocatedobjects.com/sitemap.xml
## Citing
Please cite posts as "Jake Marsh, Deallocated Objects" with the post title and its HTML URL, not the .md URL. Posts from 2010-2015 are archived as originally written, so check the publish date before treating anything Apple-platform-specific as current.
## Posts
- [Mew Is Finally Under The Truck](https://deallocatedobjects.com/posts/mew-is-finally-under-the-truck.md) (2026-12-04, link post):
Tom Mason's Pokémon Childhood Version romhack makes the gen 1 playground legends real, Mew under the truck included.
这份文件值得抄的地方有三处:
- 第一段就把「这是什么站、覆盖什么主题、时间跨度」说清,代理不用再去猜站点定位;
- 「Markdown for agents」自成一节,把两种取法(加
.md、发Accept头)和会返回Vary: Accept都写明,代理读到这里就知道下一步该干什么; - 「Citing」明确要求引用 HTML URL 而不是 .md URL,避免自己的纯文本副本被当成原文到处转。
3. llms-full.txt 怎么放、放多少
这份合订本是 656,662 字节 / 9,128 行,等于把全站正文塞进一个文件。好处是"一次拿全",代价是大概率超过代理单次读取上限(Claude Code 单次读取约 100KB 量级,超出就要分块续读)。所以他的分工是:
- 要"全":
llms-full.txt,适合离线索引、批量灌库; - 要"准":
llms.txt的清单 + 单篇.md,适合按需取一页; - 要"快":
search.json/feed.json,适合先定位再取文。
三个文件不是互相替代,是按"取文粒度"分层。只做一个 llms-full 就指望代理读全,是这类做法最常见的失效点。
4. 内容协商:同一个 URL 回两种格式
代理不必知道 .md 存在。在 Accept 头里要 markdown,普通文章 URL 直接回 markdown。原文给出的 nginx 思路是"一个 map + 每个 location 一行判断",下面是按其描述复述的最小可跑版(非原文逐字):
# http 段:把 Accept 头映射成后缀
map $http_accept $md_suffix {
default "";
"~*text/markdown" ".md";
}
server {
# 文章页:要 markdown 就内部 rewrite 到 .md
location ~ ^/posts/[^/.]+$ {
if ($md_suffix) { rewrite ^ $uri.md last; }
}
location ~ \.md$ {
default_type "text/markdown; charset=utf-8";
add_header Vary "Accept";
add_header Link '</llms.txt>; rel="describedby"; type="text/plain"; title="Guide for AI agents"';
add_header X-Robots-Tag "noindex, follow";
}
}
三个响应头是这套配置的重点,缺一个就出问题:
Vary: Accept—— 不加,CDN 或反向代理会把 HTML 缓存回给要 markdown 的请求,协商等于没生效;Link: </llms.txt>; rel="describedby"—— 让代理从任意页面都能反查到导览文件(这是 v2 关系属性里最实用的一条);X-Robots-Tag: noindex, follow——.md是重复内容,不能被搜索索引,但要允许顺着里面的链接爬。
5. robots.txt:把代理点名放行
# Deallocated Objects welcomes search engines and AI agents.
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /search?
Disallow: /review/
Content-Signal: ai-train=yes, search=yes, ai-input=yes
# AI search, answer engines, assistants and training crawlers: same rules as everyone else
User-agent: ClaudeBot
User-agent: Claude-SearchBot
User-agent: Claude-User
User-agent: anthropic-ai
User-agent: GPTBot
User-agent: OAI-SearchBot
User-agent: ChatGPT-User
User-agent: PerplexityBot
User-agent: Perplexity-User
User-agent: Google-Extended
User-agent: GoogleOther
User-agent: Applebot
User-agent: Applebot-Extended
User-agent: Bingbot
User-agent: meta-externalagent
User-agent: CCBot
User-agent: Amazonbot
User-agent: DuckAssistBot
User-agent: MistralAI-User
User-agent: cohere-ai
Allow: /
Disallow: /admin/
Disallow: /search?
Disallow: /review/
Content-Signal: ai-train=yes, search=yes, ai-input=yes
Sitemap: https://deallocatedobjects.com/sitemap.xml
值得注意的两点:旧标识 anthropic-ai 与 ClaudeBot 是分开写的,只写一个会漏掉一部分流量;Content-Signal 是 Cloudflare 主张的附加声明,不是 robots 标准的一部分,写不写取决于站方态度,但不能指望它被所有爬虫认。
结果:本机实测(2026-12-06)
原文没有给流量、引用次数这类量化数据,只有定性判断。为了确认配置真的生效,按下述命令做了三次实测,输出如下:
$r = Invoke-WebRequest "https://deallocatedobjects.com/posts/making-my-blog-readable-by-ai-agents" `
-Headers @{"Accept"="text/markdown"} -UseBasicParsing
"$($r.StatusCode) $($r.Headers['Content-Type']) $($r.RawContentLength)"
$r.Headers['Vary']; $r.Headers['Link']; $r.Headers['X-Robots-Tag']
200 text/markdown; charset=utf-8 5657
Vary: Accept-Encoding, Accept
Link: </llms.txt>; rel="describedby"; type="text/plain"; title="Guide for AI agents",
</sitemap.xml>; rel="sitemap"; type="application/xml",
</feed>; rel="alternate"; type="application/atom+xml",
<https://deallocatedobjects.com/posts/making-my-blog-readable-by-ai-agents>; rel="canonical"
X-Robots-Tag: noindex, follow
四项都对:
| 检查项 | 期望 | 实测 |
|---|---|---|
直接访问 /llms.txt | 200 + text/plain + 首行 # | 200,43,888 字节,215 行,首行 # Deallocated Objects |
.md 端点 | 200 + text/markdown | 200,5,657 字节,首行是 frontmatter --- |
| Accept 协商 | 同一 URL 回 markdown | 200,text/markdown,5,657 字节(与 .md 一致) |
| Vary / noindex | 两个头都在 | Vary: Accept-Encoding, Accept;X-Robots-Tag: noindex, follow |
同一篇文章,HTML 页与 .md 是同一份内容的两种形态,.md 只有 5,657 字节——代理省掉的是模板与脚本的解析成本,收获的是"一次就抓到正文"。
至于效果,作者的表述很克制:这套东西的价值是让代理少出错,不是替代基础 SEO。本文也不替它宣称引用量或排名变化。
复盘
三条可以直接抄的配置项
map $http_accept $md_suffix+if ($md_suffix) { rewrite ^ $uri.md last; }:一个 map 管全站,比给每个页面单独开.md链接省事。- 三个响应头成对出现:
Vary: Accept(防缓存串味)、Link ... rel="describedby"(指回 llms.txt)、X-Robots-Tag: noindex, follow(不索引但可跟链)。 - robots.txt 里对 AI 爬虫具名写一遍,并且把
anthropic-ai与ClaudeBot分开列;全站放行,只封/admin/、/search?、/review/。
两条踩坑提醒
- 只做
llms-full.txt等于没做。656KB / 9,128 行远超代理单次读取上限,代理只会读到开头一段。必须保留llms.txt清单 + 单篇.md这两级粒度。 - 没有
Vary: Accept的内容协商是假协商。站点一上 CDN,先缓存到的 HTML 会被原样返回给要 markdown 的请求;排查时先看Vary,再看Content-Type。 - 补一条边界:这套做法要求能改服务器配置。纯 SaaS 内容站、托管型博客、不能碰 nginx 的平台,第二、三条都落不了地——只能退回到"提供
.md静态副本 + llms.txt 索引"。
标注
- llms.txt 版本:v1 结构(H1 站点名 + 分节清单 + Markdown 链接),并落地了 v2 的关系属性之一(HTTP
Link: rel="describedby"指回 llms.txt)。 - 规范状态:llms.txt 由 Jeremy Howard 提出,不是 W3C/IETF 标准,也未被 LLM 厂商官方确认为读取协议;Google 明确表示不支持。
Content-Signal是 Cloudflare 的主张,同样非标准。 - 来源:作者原文 https://deallocatedobjects.com/posts/making-my-blog-readable-by-ai-agents (2026-10-24);本文配置片段与实测数据均于 2026-12-06 本机复核,nginx 片段为按原文描述复述的最小可跑版,非原文逐字。
- 数据口径:字节数、行数、响应头为本机
Invoke-WebRequest实测;原文未提供引用量、排名、工单量等量化结果,本文不作补充。
标签:llms.txt、AI可见度、AIWO、结构化暴露、独立开发者博客