一句话: Sitemap 是一份"我希望被搜索引擎看到的 URL 清单",告诉 Google 哪些页面重要、什么时候更新、有没有视频/图片/news/多语言版本。它是 hint 不是 command — 提交了 ≠ 保证收录,但能显著提升大站、新站、富媒体站的发现效率。
TL;DR — 该不该做 sitemap
| 你的网站长这样 | 建议 |
|---|---|
| ≥500 页 + 内链不完整 | 做 |
| 新站没什么外链 | 做 |
| 有大量图片/视频/新闻 | 做 |
| 用 WordPress / Wix / Blogger 等 CMS | CMS 已经做了,你啥也不用干 |
| < 500 页且全部内链可达 | 不必,Google 自己能爬完 |
| 没视频/图片/新闻不需要进对应垂搜 | 不必 |
Part 1 — 3 种 sitemap 格式选型
Google 不偏好任何一种。根据你的 CMS 和需求选。
| 格式 | 优点 | 缺点 | 适用 |
|---|---|---|---|
| XML sitemap | 最灵活 — 支持 image/video/news/hreflang 4 大扩展;CMS 多数能自动生成 | 写起来繁琐;大站维护成本高 | 默认首选,尤其有富媒体 |
| RSS / mRSS / Atom 1.0 | CMS 多数自动生成;mRSS 支持 video | 只能传最近的 URL(不是全部);除文字外只支持 video,不支持 image/news | 已有 RSS 源、且只关心新增页 |
| Text sitemap | 极简 — 一行一个 URL | 只能 HTML 文本页,扩展全部不支持 | 纯文本站 + 大量 URL + 不需要富媒体 |
1.1 XML sitemap 最小示例
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/foo.html</loc>
<lastmod>2022-06-04</lastmod>
</url>
</urlset>
1.2 ⚠️ 关于 <priority> 和 <changefreq>
Google 完全忽略。别浪费时间设。
1.3 ⚠️ 关于 <lastmod>
- 必须真实 — 改 copyright 年份 / 改一个小字不算 "significant update"
- "Significant update" = 主内容改、structured data 改、链接改
- 如果你日期不准 → Google 会直接忽略整个
<lastmod>字段 → 失去这个调度信号 - 这是少数会"教训作弊"的字段
1.4 Text sitemap 示例
https://www.example.com/file1.html
https://www.example.com/file2.html
文件名随意,必须 .txt 扩展名。文件内只放 URL 一行一个,不要任何其他东西。
Part 2 — 通用 Best Practice (所有格式都适用)
2.1 硬上限(超了必拆)
- 单文件 ≤ 50MB(未压缩)
- 单文件 ≤ 50,000 个 URL
- 编码 必须 UTF-8
超出任一限制 → 必须拆成多个 sitemap + 用 sitemap index。
2.2 URL 格式
- 必须绝对 URL — 用
https://www.example.com/mypage.html,不能/mypage.html - 必须放 canonical URL — 一个内容多个 URL 时,只放你希望 Google 显示的那一个
- 桌面/移动两个 URL 的话,只放一个版本(或者两个都放但要在 markup 里标
mobile-first-indexing注解)
2.3 sitemap 文件位置 = scope 边界
| 放在 | 影响范围 |
|---|---|
https://example.com/sitemap.xml(根目录) |
整站全部 ✅ 推荐 |
https://example.com/subdir/sitemap.xml |
只对 /subdir/ 及其子目录有效 |
| 通过 Search Console 提交 | scope 不受文件位置限制 |
原则: 默认放根目录,除非你有 specific 需求。
2.4 URL 顺序不重要
Google 不在乎你 sitemap 里 URL 排序。爱怎么排怎么排。
Part 3 — 怎么生成 sitemap (3 种打法)
A. 让 CMS 自动生成(首选)
WordPress / Wix / Blogger / Shopify 等都自动有了。Google 一下 "wix sitemap" 或 "blogger RSS" 看你的 CMS 怎么暴露的。
B. 手动写(< 几十个 URL 才可行)
记事本 / nano 一行一行写。维护成本极高,不推荐给 ≥几十页的站。
C. 工具/脚本自动生成(几十~50,000 URL)
最佳实践:从你网站数据库导出 URL 列表 → 输出 sitemap 文件。让网站系统直接生成是最稳定的,因为每次发新内容 sitemap 自动更新。
第三方工具列表(老但能用):code.google.com/p/sitemap-generators/wiki/SitemapGenerators。
Part 4 — Sitemap Index (大站方案)
4.1 何时需要
- 单 sitemap 接近 50MB 或 50,000 URL 上限
- 想在 Search Console 里单独追踪每个 sitemap 的索引情况(对应不同板块 / 内容类型)
4.2 示例
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap1.xml.gz</loc>
<lastmod>2024-08-15</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap2.xml.gz</loc>
<lastmod>2022-06-05</lastmod>
</sitemap>
</sitemapindex>
注意:子 sitemap 可以是 .xml.gz 压缩格式,大站强烈推荐压缩传输。
4.3 硬规则
| 规则 | 上限 |
|---|---|
| 一个 sitemap index 内最多 sitemap 数 | 50,000 个 <loc> |
| 一个站点最多 sitemap index 数 | 500 个 |
| 子 sitemap 必须 同站点 托管 | 例外: cross-site submission(见 Part 9) |
| 子 sitemap 必须在 sitemap index 的同级目录或更深 | 例: index 在 /public/sitemap_index.xml 只能引用 /public/* 或 /public/sub/* 下的 sitemap |
4.4 必填/可选标签
| 标签 | 必填? | 说明 |
|---|---|---|
<sitemapindex> |
✅ | 根标签 |
<sitemap> |
✅ | 每个子 sitemap 一个 |
<loc> |
✅ | 子 sitemap 的 URL |
<lastmod> |
❌ | 帮 Google 调度抓取优先级,强烈推荐 |
Part 5 — 4 大 Extension 命名空间
| Extension | 命名空间 URL |
|---|---|
image: |
http://www.google.com/schemas/sitemap-image/1.1 |
news: |
http://www.google.com/schemas/sitemap-news/0.9 |
video: |
http://www.google.com/schemas/sitemap-video/1.1 |
xhtml:(hreflang 多语言) |
http://www.w3.org/1999/xhtml |
5.1 组合声明(一个 sitemap 用多个 extension)
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<!-- 接下来 news + video + xhtml 标签可以混用 -->
</url>
</urlset>
5.2 标签顺序无所谓
只要 <loc> 在最前。其他扩展标签顺序随意。
5.3 ⚠️ 多扩展显著增大文件
50MB 上限要警惕。可能要更早拆 sitemap index。
Part 6 — Image Sitemap
6.1 用途
告诉 Google 它平时爬不到的图片(典型: JavaScript 动态注入的图)。
6.2 完整示例
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com/sample1.html</loc>
<image:image>
<image:loc>https://example.com/image.jpg</image:loc>
</image:image>
<image:image>
<image:loc>https://example.com/photo.jpg</image:loc>
</image:image>
</url>
</urlset>
6.3 必填字段
| 标签 | 说明 |
|---|---|
<image:image> |
一张图一个,每个 <url> 最多 1000 张 |
<image:loc> |
图片 URL |
6.4 跨域名图片(CDN)
可以,但必须在 Search Console 把图片所在域名也验证(比如用 Google Sites 托图,要验证那个域名)。且 robots.txt 不能 disallow 这些图。
6.5 已废弃的字段(2022 春季清理)
❌ <image:caption>、<image:geo_location>、<image:title>、<image:license> — 不要再用,Google 已经无视。
Part 7 — Video Sitemap
7.1 用途
告诉 Google 新发的视频 + 它爬不到的视频(JS 加载、外站嵌入等)。
7.2 关键必填字段
| 标签 | 说明 |
|---|---|
<video:video> |
一个视频一个,可在一个 <url> 下嵌套多个 |
<video:thumbnail_loc> |
缩略图 URL(缩略图要求) |
<video:title> |
视频标题,需与页面一致,HTML 实体必须转义或 CDATA 包裹 |
<video:description> |
视频描述,最多 2048 字符,需与页面一致(不必逐字) |
<video:content_loc> 或 <video:player_loc> |
二选一必填 |
7.3 content_loc vs player_loc 选哪个
<video:content_loc>优先:指向原始视频文件(.mp4 等)。Google 抓取最高效。HTML 和 Flash 不支持。不能等于<loc>。<video:player_loc>备选:指向播放器 URL(<embed src=>的内容)。YouTube / Vimeo 等嵌入站只能用这个。
想限制访问但还让 Google 看得到? 用 verifying Googlebot 反向 IP 验证 + 白名单。
7.4 关键可选字段
| 标签 | 说明 |
|---|---|
<video:duration> |
秒,1~28800(8 小时) |
<video:expiration_date> |
W3C 日期格式,过期后不显示在搜索 |
<video:rating> |
0.0~5.0 浮点 |
<video:view_count> |
播放次数 |
<video:publication_date> |
首次发布时间(W3C 格式) |
<video:family_friendly> |
yes/no,默认 yes,SafeSearch 控制 |
<video:restriction relationship="allow">CA MX</video:restriction> |
ISO 3166 国家码,空格分隔。允许/拒绝某些国家显示 |
<video:platform relationship="allow">web tv</video:platform> |
web / mobile / tv,限制某些设备 |
<video:requires_subscription> |
yes/no |
<video:uploader info="..."> |
上传者名(≤255 字符)+ 可选个人页 URL(同域) |
<video:live> |
yes/no |
<video:tag> |
标签,每视频最多 32 个,一个 tag 一个元素 |
7.5 已废弃字段(2022 春季清理)
❌ <video:category>、<video:gallery_loc>、<video:price>(及全部属性)、<video:tvshow>(及全部属性)、<video:player_loc> 的 autoplay 和 allow_embed 属性 — 不要再用。
7.6 视频 sitemap 抓取限制
- 视频文件 URL 不能被 robots.txt disallow
- 不能要登录 / metafile
- 不能被防火墙挡 Googlebot
- 必须 HTTP 或 FTP 协议,流协议不支持
7.7 mRSS 替代方案
Google 也支持 mRSS feed 给视频用,跟 video sitemap 等价,只是格式不同。CMS 自动出 RSS 的话省事一些。结构必填:<media:content> (含 medium="video" + url 或 <media:player>) + <media:title> + <media:description> + <media:thumbnail>。
Part 8 — News Sitemap
8.1 用途
仅 news publisher 用。告诉 Google News 你的新闻文章。
8.2 5 条铁律 ⭐⭐⭐
- 只放最近 2 天发的文章。超过 2 天的 URL 要么从 sitemap 删掉,要么去掉
<news:news>元数据。 - 更新现有 sitemap,不要每次发新文章建新 sitemap。
<news:name>必须与 news.google.com 上展示的发布物名完全一致(去掉括号内容)。<news:publication_date>是首次发布时间,不是你写进 sitemap 的时间。- 一个 sitemap 最多 1000 个
<news:news>标签(超了拆 sitemap index)。
Empty Sitemap warning: 如果好几天没发新闻,sitemap 可能空了,Search Console 会警告。这不是错误,Google 只是想确认你是有意的。空着不影响搜索。
8.3 完整必填字段
| 标签 | 说明 |
|---|---|
<news:news> |
父标签,每 <url> 最多一个 |
<news:publication> |
父标签,含 name + language |
<news:name> |
发布物名,必须匹配 news.google.com |
<news:language> |
ISO 639 语言码(2-3 字母)。简中用 zh-cn,繁中用 zh-tw |
<news:publication_date> |
W3C 格式日期/时间。用首发时间不是入 sitemap 时间。 |
<news:title> |
文章标题。不要塞作者名/发布物名/日期,Google 会自动加这些。 |
8.4 示例
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>http://www.example.org/business/article55.html</loc>
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2008-12-23</news:publication_date>
<news:title>Companies A, B in Merger Talks</news:title>
</news:news>
</url>
</urlset>
Part 9 — Submit sitemap 的 4 种方式
方式 1: Search Console(推荐)
Sitemaps report 提交。最大优势:看到 Google 何时访问、何时报错、处理状态。
方式 2: Search Console API
程序化提交: /webmaster-tools/v1/sitemaps/submit。适合自动化 / 大量 sitemap 管理。
方式 3: robots.txt 声明
Sitemap: https://example.com/my_sitemap.xml
位置任意,Google 下次爬 robots.txt 时发现。
方式 4: WebSub(只 Atom/RSS)
RSS/Atom 用 WebSub 广播变更给搜索引擎,实时推送。
⚠️ 共识
提交 sitemap 只是 hint,不保证 Google 真的去下载或用它来爬。提交完不见效果 → 看 Search Console 的 Sitemaps report 错误。
Part 10 — 跨站点 sitemap 提交
如果你管多个域名,可以一份 sitemap 写多站 URL,简化提交。
10.1 两种打法
A. 一个 sitemap 多个域
https://host1.example.com/sitemap.xml 内容:
- https://host1.example.com
- https://host2.example.com
- https://host3.example.com
- https://host1.example.ch
B. 多个 sitemap 集中在一个位置
https://host1.example.com/host1-example-sitemap.xml
https://host1.example.com/host2-example-sitemap.xml
https://host1.example.com/host3-example-sitemap.xml
10.2 必要前提
- Search Console 中验证全部相关站点的所有权
- 走 Search Console 提交,或 在每个站的
robots.txt里引用其对应 sitemap:
# https://example.com/robots.txt
sitemap: https://sitemaps.example.com/sitemap-example-com.xml
Part 11 — 多语言 sitemap (hreflang via xhtml extension)
在 sitemap 里直接声明语言/地区版本,等价于 HTML 的 <link rel="alternate" hreflang="..."> 但更集中、好维护。
<url>
<loc>https://www.example.com/english/page.html</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://www.example.de/deutsch/page.html"/>
<xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.de/schweiz-deutsch/page.html"/>
<xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/page.html"/>
</url>
注意: 每个 <url> 必须列全所有语言版本(包括它自己)。漏掉自己 Google 不会自动补。详见 国际化 (hreflang/多语言/多地区) + 显式内容 (SafeSearch/Adult) 完全指南(后续 wiki)。
Part 12 — 13 条反 pattern(常见错误)
| # | 反 pattern | 后果 |
|---|---|---|
| 1 | 设 <priority> / <changefreq> |
白费力气,Google 完全忽略 |
| 2 | <lastmod> 每次发布都改成"今天" / 不准 |
Google 直接忽略整个字段 |
| 3 | sitemap 放 /subdir/ 但想影响根 |
scope 仅对子目录有效,要么挪根、要么走 Search Console 提交 |
| 4 | 用相对 URL | Google 会"按字面"爬,大概率 404 |
| 5 | 列 mobile + desktop 同一页两个 URL 不做注解 | canonical 信号混乱 |
| 6 | 单 sitemap 超 50MB 或 50,000 URL 不拆 | Google 报错或截断 |
| 7 | News sitemap 留 ≥2 天的文章 | 违反 News 规则 |
| 8 | News sitemap 的 <news:name> 跟 news.google.com 不匹配 |
文章拒收 |
| 9 | News sitemap 标题里塞作者/日期 | 重复显示,Google 推荐去掉 |
| 10 | 图片 sitemap 还在用 <image:caption> / <image:title> / <image:license> |
已废弃,被忽略 |
| 11 | video sitemap 用 <video:price> / <video:category> |
已废弃,被忽略 |
| 12 | 视频内容 URL <video:content_loc> 等于页面 <loc> |
解析失败 |
| 13 | XML 字符没转义 | XML 解析失败,整个 sitemap 报废 |
Part 13 — Troubleshooting
任何 sitemap 问题去 Search Console Sitemaps troubleshooting guide 查。常见错:
- HTTP 错 — 文件 404 / 500 / 重定向链
- XML parse 错 — 实体没转义、namespace 拼错、
<loc>缺 - URL 错 — 相对 URL、跨域且未验证、被 robots.txt block
- Empty Sitemap warning(news 专属) — 见 Part 8.2,一般可忽略
Part 14 — 相关 wiki
- 想知道 Googlebot 怎么找你: Google SEO 入门 + Search 工作原理 + Search Essentials 的 crawl/index/serve 三阶段
- 文件类型 / 索引规则: Googlebot 抓取机制与索引控制完全指南 (URL/Links/Mobile-first/Meta/Testing/AMP)(后续 wiki)
- robots.txt / robots meta tag: 抓取与索引控制完全指南 (robots.txt / noindex / X-Robots-Tag / data-nosnippet / rel)(后续 wiki)
- canonical / 重定向: Canonical / 重定向 / 网站迁移完全指南 (含 HTTP 状态码全表 + 503 临时停业 playbook)(后续 wiki)
- 国际化(hreflang/locale): 国际化 (hreflang/多语言/多地区) + 显式内容 (SafeSearch/Adult) 完全指南(后续 wiki)
- 图片 SEO: 富功能 / Discover / Images / Video / Page Experience / Web Stories / SXG / Paywall 完全指南 中 Google Images 部分
- 视频 SEO: 富功能 / Discover / Images / Video / Page Experience / Web Stories / SXG / Paywall 完全指南 中 video 部分
Last updated
2026-05-17 — 基于 Google Search Central 7 篇 sitemaps 系列(2025-12 最新)整理。包含 2022 春季扩展清理后的最新字段集。
来源与关联资料
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/combine-sitemap-extensions?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/combine-sitemap-extensions?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/image-sitemaps?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/image-sitemaps?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/video-sitemaps?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/video-sitemaps?hl=zh-cn
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap?hl=en
- https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap?hl=zh-cn