让网站同时对 Google 和 AI Agent 友好:一份 2026 年实操指南
让网站同时对 Google 和 AI Agent 友好
写这篇文章是因为我刚搭完这个网站,发现 2026 年做个人站点,已经不只是”讨好 Google”那么简单了 —— AI Agent 也是你的读者,而且它们读的方式跟人不一样。
搜索引擎的需求(Google / Bing)
这些你大概都懂:
- 语义化 HTML:
<article>/<section>/<nav>/<time>标签用起来 - 标题层级:H1 一页一个、H2 划分章节、H3 划分子节
- meta description + canonical URL
- 结构化数据:Schema.org JSON-LD(
@type: Article、@type: Person等) - Open Graph + Twitter Card:分享到社交平台时好看
- sitemap.xml:告诉搜索引擎有哪些页面
- 速度快、移动端适配:Core Web Vitals
AI Agent 的需求(GPTBot / ClaudeBot / PerplexityBot)
这些容易被忽略,但 2026 年越来越重要:
1. robots.txt 显式放行
User-agent: GPTBot
Allow: /
User-agent: ClaudeBot
Allow: /
User-agent: anthropic-ai
Allow: /
User-agent: PerplexityBot
Allow: /
不显式 Allow,AI 爬虫会犹豫要不要抓。
2. llms.txt
这是 2024 年新出的标准(llmstxt.org),专门给大语言模型看的站点索引:
# 我的网站
> 简短描述
## 文章
- [标题](url) (日期): 摘要
很多 AI Agent 会先抓这个文件,再决定要不要抓全站。
3. JSON Feed(不只是 RSS)
JSON Feed 1.1 是比 RSS 更现代的格式:
{
"version": "https://jsonfeed.org/version/1.1",
"title": "...",
"items": [{ "id": "...", "title": "...", "content_text": "...", "date_published": "..." }]
}
结构化数据天生适合 LLM 解析。
4. 纯 Markdown 版本
有些爬虫偏好 .md 而不是渲染好的 HTML。可以暴露 /index.md 给它们。
一份够用的最小实现
如果你用 Astro:
// src/pages/llms.txt.ts
export const GET = async () => {
const posts = await getCollection('posts');
let md = `# 站点名\n\n## 文章\n\n`;
for (const p of posts) {
md += `- [${p.data.title}](${SITE.url}/posts/${p.slug}): ${p.data.description}\n`;
}
return new Response(md, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
};
Astro 还自带 @astrojs/sitemap 集成,npm run build 时自动生成。
总结
2026 年的好网站 = Google 友好 + AI Agent 友好。
把上面这些做了,你的网站在两个世界都吃得开。