AI 智能体支持
本页介绍的功能仍处于实验阶段,适合早期采用和评估。后续版本可能会调整输出细节和验证范围。要跟踪智能体支持功能的阶段性演进,请参阅 Improve support for AI-agent doc consumption #2614。
功能
站点显式启用后,OINK 会提供以下面向用户和机器可读的行为:
- 支持 Markdown 输出格式。项目的
outputs配置决定哪些页面类型发布 Markdown。 - 发现机制:页面 HTML 的 header 会包含指向该页 Markdown 版本的
rel="alternate"链接。 - 查看 Markdown:页面元信息区域会显示指向 Markdown 版本的“查看 Markdown”链接。
llms.txt:位于站点根目录的内容清单文件。
本页其余部分介绍如何启用各项功能,并结合示例讨论相应的验证与指标。
启用 Markdown 输出
Hugo 提供多种内置输出格式,其中包括
markdown。要启用 Markdown 输出,请在 Hugo 的 outputs 配置中,把 markdown
加入需要支持的页面类型。例如:
outputs:
home: [HTML, markdown]
page: [HTML, markdown]
section: [HTML, RSS, print, markdown]
[outputs]
home = [ "HTML", "markdown" ]
page = [ "HTML", "markdown" ]
section = [ "HTML", "RSS", "print", "markdown" ]
{
"outputs": {
"home": ["HTML", "markdown"],
"page": ["HTML", "markdown"],
"section": ["HTML", "RSS", "print", "markdown"]
}
}
让页面退出 Markdown 输出
默认情况下,无论 Hugo 的 outputs 映射位于多文件站点配置还是页面 front
matter 中,它都会对每种页面类型执行 完整替换,而不是合并1。添加
markdown 时,请保留站点已经依赖的所有格式,例如以上示例中分区使用的 RSS 和
print。
如果要让某些页面不输出 Markdown,请在页面 front matter 中把 outputs 设为仅
HTML,或者在排除 markdown 的同时列出该页原本的全部默认输出格式。例如:
---
title: HTML-only test page
outputs: [HTML]
---
...
启用 llms.txt
llms.txt
是一种简单的文本格式,用来列出指向站点机器可读内容的链接。智能体可以轻松发现和解析它,它也能补充信息更丰富但结构更复杂的 Markdown 输出。进一步了解请参阅
llmstxt.org。
OINK 会在站点根目录生成
llms.txt,其中包含首页、主菜单页面,以及存在时的 Markdown 备用版本链接。要启用它,请在 Hugo 的
outputs 配置中为首页添加 LLMS。例如:
outputs:
home: [HTML, markdown, LLMS]
page: [HTML, markdown]
section: [HTML, RSS, print, markdown]
本站生成的 llms.txt 示例请参阅 /llms.txt。
自定义输出
OINK 通过 layouts/all.md 渲染 Markdown 输出,并通过 layouts/index.llms.txt
生成 llms.txt。你可以在多个层级覆盖默认行为:
- 按类型:在项目的
layouts/下添加home.md或_default/single.md等模板,为特定 Hugo 类型定制 Markdown 输出。 - 按短代码:为项目本地短代码添加输出格式专属短代码模板,使其在适当场景输出便于 Markdown 使用的内容。
- 按页面:为需要精心设计智能体视图的高价值页面提供专属内容或结构。
服务端支持
虽然不属于 OINK 的支持范围,站点仍可通过服务端内容协商,帮助智能体发现和访问 Markdown 内容。例如,在与 HTML 相同的 URL 上响应
Accept: text/markdown。
验证与指标
我们使用 AFDocs
评估面向智能体内容的基础结构支持,并验证生成的输出是否满足配置的检查项。我们也鼓励站点针对智能体访问模式实现自己的监控和指标,例如记录对 Markdown
URL 或 llms.txt
的请求,并统计其使用情况。详情请参阅智能体支持检查。
oink.pgsty.com 项目包含 AFDocs
配置和 npm 脚本,维护者可据此对已部署 URL 评分。这些检查与 OINK 的智能体支持目标有重合,包括 Markdown
URL、llms.txt 和相关类别。
评分表示例
评分表示例包括:
-
OpenTelemetry 智能体评分在线报告;
-
本站的 AFDocs 评分表:
oink.pgsty.com评分表Running in oink.pgsty.com…
Agent-Friendly Docs Scorecard
http://localhost:1313 · 4/26/2026, 5:43:59 AM
Overall Score: 100 / 100 (A+)
Category Scores: Content Discoverability 100 / 100 (A+) Markdown Availability 100 / 100 (A+) Page Size and Truncation Risk 100 / 100 (A+) Content Structure 100 / 100 (A+) URL Stability and Redirects 100 / 100 (A+) Observability and Content Health 100 / 100 (A+) Authentication and Access 100 / 100 (A+)
Check Results:
Content Discoverability PASS llms-txt-exists llms.txt found at 1 location(s) PASS llms-txt-valid llms.txt follows the proposed structure (H1, blockquote, heading-delimited link sections) PASS llms-txt-size llms.txt is 1,131 characters (under 50,000 threshold) PASS llms-txt-links-resolve All 13 same-origin links resolve (13 total links) PASS llms-txt-links-markdown 13/13 same-origin links point to markdown content (100%) PASS llms-txt-directive llms.txt directive found in all 13 pages, near the top of content Markdown Availability PASS markdown-url-support 13/13 pages support .md URLs (100%) PASS content-negotiation 13/13 pages support content negotiation (100%) Page Size and Truncation Risk PASS rendering-strategy All 13 pages contain server-rendered content PASS page-size-markdown All 13 pages under 50K chars (median 2K, max 9K) PASS page-size-html All 13 pages convert under 50K chars (median 2K, 0% boilerplate) Content Structure PASS tabbed-content-serialization No tabbed content detected across 13 pages PASS section-header-quality No tabbed content found; header quality check not applicable PASS markdown-code-fence-validity All 1 code fences properly closed across 14 pages URL Stability and Redirects PASS http-status-codes All 13 pages return proper error codes for bad URLs PASS redirect-behavior No redirects detected across 13 pages Observability and Content Health PASS cache-header-hygiene All 14 endpoints have appropriate cache headers Authentication and Access PASS auth-gate-detection All 13 pages are publicly accessible SKIP auth-alternative-access All docs pages are publicly accessible; no alternative access paths neededFull spec: https://agentdocsspec.com/spec/
这些检查的配置详情请参阅智能体支持检查。
-
这与 Hugo 文档描述的 front matter 配置行为不同,但截至 Hugo 0.158.0,我们的测试确认实际行为如此。 ↩︎