SEO
每一页都是构建时生成的完整 HTML,带有 canonical、hreflang、Open Graph 与结构化数据;站点地图、robots.txt 与重定向自动生成。
静态 HTML
ButterIX 在构建时用 React 服务端渲染输出每一页的完整 HTML,不依赖浏览器端 JavaScript 渲染内容。搜索引擎爬虫、社交平台的链接预览和 AI 爬虫拿到的,就是读者看到的全部内容——正文、代码示例、API 参数表一应俱全。
页面之间的跳转由一个很小的客户端脚本无刷新完成,并通过 Speculation Rules 预取链接,但这只是体验优化:关闭 JavaScript,站点依然可以完整浏览。
每页输出的 head
以本页为例,构建器会输出:
<title>SEO · ButterIX</title>
<meta name="description" content="ButterIX 的 SEO 能力:静态 HTML、标题模板与 meta……">
<link rel="canonical" href="https://acme-payments-sites.butterix.com/guides/features/seo">
<link rel="alternate" hreflang="zh" href="https://acme-payments-sites.butterix.com/guides/features/seo">
<link rel="alternate" hreflang="x-default" href="https://acme-payments-sites.butterix.com/guides/features/seo">
<link rel="alternate" hreflang="en" href="https://acme-payments-sites.butterix.com/en/guides/features/seo">
<link rel="alternate" type="text/markdown" href="/guides/features/seo.md" title="Markdown">
<meta property="og:type" content="article">
<meta property="og:site_name" content="ButterIX">
<meta property="og:title" content="SEO · ButterIX">
<meta property="og:url" content="https://acme-payments-sites.butterix.com/guides/features/seo">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@bitidocs">
<script type="application/ld+json">{"@type":"TechArticle", …}</script>
<script type="application/ld+json">{"@type":"BreadcrumbList", …}</script>| 输出 | 来源 |
|---|---|
<title> | seo.title-template(默认 {page} | {site});页面标题可用 frontmatter og:title 覆盖 |
| description | frontmatter description → og:description → subtitle → 正文摘要 |
| keywords | frontmatter keywords |
og:image | frontmatter og:image → seo.og-image;有图片时 Twitter 卡片自动变为 summary_large_image |
article:modified_time | frontmatter last-updated |
robots | 页面 noindex、导航中的 noindex、seo.noindex 或预览部署时输出 noindex, nofollow |
字段说明见页面元数据与 docs.yml › SEO。
canonical
- 默认是页面自身的绝对地址,域名使用站点的主域名。
- 旧版本页面的 canonical 指向默认版本中的同一页面,避免多个版本的相似内容互相竞争排名。见多版本。
- frontmatter
canonical-url可以手动指定。
结构化数据
每页输出两段 JSON-LD:
TechArticle:标题、描述、地址、语言(inLanguage)、dateModified(设置了last-updated时)以及所属WebSite。BreadcrumbList:由导航中的分区路径生成,与页面上的面包屑一致。
sitemap.xml
/sitemap.xml 包含全部页面(所有语言与版本,noindex 页面与更新日志的日期详情页除外),每个地址都附带其他语言版本的 xhtml:link:
<url>
<loc>https://acme-payments-sites.butterix.com/guides/features/seo</loc>
<xhtml:link rel="alternate" hreflang="zh" href="https://acme-payments-sites.butterix.com/guides/features/seo"/>
<xhtml:link rel="alternate" hreflang="en" href="https://acme-payments-sites.butterix.com/en/guides/features/seo"/>
</url>robots.txt 与 AI 爬虫
默认的 robots.txt 允许所有爬虫,并声明站点地图:
User-agent: *
Allow: /
Sitemap: https://acme-payments-sites.butterix.com/sitemap.xml声明内容用途
seo.content-signal 在 robots.txt 中输出 Content-Signal,说明内容可以用来做什么。三项都是可选的布尔值,没写的不输出:
seo:
content-signal:
search: true # 建立搜索索引
ai-input: true # 作为 AI 回答的输入
ai-train: false # 训练模型User-agent: *
Content-Signal: search=yes, ai-input=yes, ai-train=no
Allow: /禁止 AI 爬虫
设置 seo.ai-crawlers: disallow 后,会额外禁止以下 AI 训练与检索爬虫:
- GPTBot
- ChatGPT-User
- OAI-SearchBot
- ClaudeBot
- Claude-User
- Claude-SearchBot
- anthropic-ai
- PerplexityBot
- Google-Extended
- Applebot-Extended
- CCBot
- Bytespider
- meta-externalagent
使用自己的 robots.txt
agents:
robots-txt: robots.txt # 相对于 docs.yml文件内容原样发布,ai-crawlers 与 content-signal 不再起作用。
seo.noindex: true 或预览部署时,robots.txt 始终为 Disallow: /,自己的文件也不例外。
文档通常希望被 AI 读到:开发者越来越多地通过 ChatGPT、Claude、Cursor 了解一个 API。ButterIX 默认允许 AI 爬虫,并提供 .md 与 llms.txt 让它们读得更准确,见 Agent 友好。
重定向
改版时用 redirects 保住旧链接的排名:
redirects:
- source: /docs/getting-started
destination: /guides/get-started/quickstart
- source: /api/v1/:endpoint
destination: /api-reference/:endpoint- 默认 301 永久重定向,
permanent: false为 302。 - 跳转时保留查询参数;访问
.md、.mdx地址时跳到目标页的 Markdown。 - 首页不是
/时,根地址会自动 302 到首页。
URL 规范化
- 页面地址没有尾斜杠;运行时把
/guides/308 重定向到/guides,避免重复地址。 - 不存在的地址返回真正的 404 状态码和
404.html(带noindex);请求的是 Markdown 时返回 Markdown 404。
性能
速度本身就是排名因素:
- 零水合:页面不需要在浏览器端重新渲染。
- 代码高亮在构建时完成,图标合并为页面内 SVG sprite,不加载图标字体。
- 构建时预压缩
.br与.gz,运行时按Accept-Encoding直接返回。 - 带哈希的静态资源(样式、脚本、字体)使用一年的
immutable缓存,HTML 每次校验。
预览部署
预览部署(拉取请求、编辑器预览、biti deploy --preview)的每一页都带 noindex,robots.txt 禁止抓取,页面顶部显示「Preview」横幅,不会与生产站点争夺索引。