内容站更新后 sitemap 没重新提交

新加了 50 篇文章,Search Console 里还显示上个月的数量——sitemap 在本地生成了但没传达到爬虫。

你一次发布了 50 篇新文章。一周后 Search Console 里 URL 数还是发布前那个数,site: 搜也搜不到新页面。sitemap 生成了,文件在线上也有,但 Google 没注意到。搜索引擎不会激进地拉 sitemap——重抓节奏取决于历史抓取行为、近期变更信号和明确的提交。sitemap 存在 ≠ sitemap 被读过。

本文说怎么确认 sitemap 正确发布、怎么强制重抓,以及让”提交”不再是人工步骤的自动化方案。

常见原因

1. sitemap 生成了但还在发旧版

build 写了新的 sitemap.xml,CDN 边缘还在返回旧的。爬虫拉到旧 URL,新的没看到。

如何判断curl -s https://yoursite.com/sitemap.xml | grep -c '<url>' 数条目数。和本地 dist/sitemap.xml 对比。

2. robots.txt 没声明 sitemap 位置

robots.txt 没写 Sitemap: 那一行,爬虫除非在 Search Console 显式提交,否则可能找不到 sitemap。

如何判断curl -s https://yoursite.com/robots.txt | grep -i sitemap。空就是没声明。

3. sitemap 当初提交过但之后没再 ping

Google 会拉提交过的 sitemap,但频率取决于观察到的更新节奏。历史上更新少的站,重抓间隔可能 1-2 周。

如何判断:Search Console > Sitemaps > 看 “Last read” 那一列。

4. lastmod 时间没更新

爬虫用 <lastmod> 判断要不要重抓。build 里 lastmod 一直是旧值,爬虫看不到任何变化信号。

如何判断:打开 sitemap.xml,看新文章是不是有近期 <lastmod>,老文章的 lastmod 是不是反映了最近一次编辑。

5. sitemap 索引和分片对不上

大站会用 sitemap index 指向多个分片。新文章进了某个分片,但 index 还引着旧版本,爬虫发现不了新内容。

如何判断curl -s https://yoursite.com/sitemap-index.xml 确认每个子 sitemap 都列出来且可访问。

6. 新 URL 被 robots.txt 或 noindex 挡了

sitemap 列了 URL,但每个 URL 上有 <meta name="robots" content="noindex">,或者在 robots.txt 里被 Disallow。爬虫拉到了、看到 noindex 就丢掉。

如何判断curl -s <new-article-url> | grep -i 'noindex'——不应该有命中。看 robots.txt 里有没有覆盖到新 URL 路径的 Disallow:

动手前先确认

  • 新文章在生产站上是真在线(用浏览器打开一篇)。
  • 记下部署完成的时间。
  • 你对该站点的 Search Console 有访问权。

需要收集的信息

  • curl -s https://yoursite.com/sitemap.xml | head -50 的输出——前几条和结构。
  • 线上 sitemap 的 <url> 总数。
  • robots.txt 内容。
  • Search Console > Sitemaps > 状态和上次读取时间。
  • Search Console > Coverage > 新 URL 在 “Discovered” 或 “Crawled” 里有没有。

一步步修复

Step 1:本地和线上的 sitemap 对一下

# 本地
grep -c '<url>' dist/sitemap.xml
head -3 dist/sitemap.xml

# 线上
curl -s https://yoursite.com/sitemap.xml | grep -c '<url>'
curl -s https://yoursite.com/sitemap.xml | head -3

数量应该一致。线上小于本地就是 CDN 缓存问题,按 CDN 缓存过期 那篇去 purge。

Step 2:robots.txt 里声明 sitemap

public/robots.txt

User-agent: *
Allow: /

Sitemap: https://yoursite.com/sitemap-index.xml

有 index 用 index 的 URL,没有就用 sitemap.xml。多个 Sitemap: 行是允许的。

rebuild 后 curl -s https://yoursite.com/robots.txt 必须能看到 Sitemap 行。

Step 3:在 Search Console 里重新提交

search.google.com/search-console > 选属性 > 左边 Sitemaps。

Add a new sitemap:
  https://yoursite.com/sitemap-index.xml

Submit

活跃属性几分钟就读,刚开站的可能久一点。

如果已经有一个 sitemap 显示 “Couldn’t fetch” 或 “Last read” 很老:

  1. 从列表里 remove 掉。
  2. 用同一个 URL 重新 add。
  3. remove + re-add 会强制重抓一次。

Step 4:直接 ping 搜索引擎

给 Google 和 Bing 程序化 ping:

# Google
curl "https://www.google.com/ping?sitemap=https://yoursite.com/sitemap-index.xml"

# Bing
curl "https://www.bing.com/ping?sitemap=https://yoursite.com/sitemap-index.xml"

会返回 200 OK,几小时内触发一次重抓。不能取代 Search Console 提交,但能立刻引起注意。

Step 5:让 <lastmod> 有意义

Astro 构建配置(astro.config.mjs):

import sitemap from "@astrojs/sitemap";

export default defineConfig({
  integrations: [
    sitemap({
      lastmod: new Date(),
      changefreq: "weekly",
      priority: 0.7,
    }),
  ],
});

要按文章精确,就让 lastmod 从文章 frontmatter 的 updatedAt(没改过的话退回 publishedAt)取。

Step 6:部署时自动 ping

GitHub Actions 加一步,每次生产部署成功后 ping:

- name: Ping search engines
  run: |
    curl -s "https://www.google.com/ping?sitemap=https://yoursite.com/sitemap-index.xml"
    curl -s "https://www.bing.com/ping?sitemap=https://yoursite.com/sitemap-index.xml"

发版清单里”提交 sitemap”这一项就消失了。

Step 7:重要页面用 URL Inspection 单页推进

特别重要的新页用 Search Console 的 URL Inspection:

Search Console 顶部搜索框 > 粘贴 URL > Inspect
> "URL is not on Google" > Request Indexing

每个属性大约一天 10 次,但对支柱内容很值。

验证

  • curl -s https://yoursite.com/sitemap.xml | grep -c '<url>' 等于你期望的数。
  • Search Console > Sitemaps > “Last read” 更新到了今天。
  • Search Console > Sitemaps > “Discovered URLs” 几天内攀到新总数。
  • site:yoursite.com/articles/new-article-slug 3-7 天能搜到。
  • 新文章 1-2 周出现在 Coverage > Indexed 里。

长期预防

  • robots.txt 永远声明 sitemap;一行的事,能消除一大类发现失败。
  • Google 和 Bing 的 ping 自动化进部署管线。
  • 每个 URL 的 <lastmod> 要准——老 lastmod 等于告诉爬虫”没变化,别看了”。
  • 5 万 URL 以上的站用 sitemap index 加分片,单文件别超过 50MB / 50000 URL 的上限。
  • 每周看一眼 Search Console 的 Coverage;突然掉或发现停滞是早期预警。

常见坑

  • 提交 sitemap URL 之前不验它返回 HTTP 200;URL 404 的话提交静默失败。
  • 在 sitemap 里列了被 robots.txt 屏蔽的 URL——爬虫会报 “Submitted URL blocked by robots.txt”。
  • 提交太频繁(每分钟一次);Search Console 会限速甚至标记属性。
  • XML 文件超过 50MB 或超过 5 万条 URL;要用 index 拆开。
  • sitemap 里混 http:// 和 https://;选定 canonical 用到底。

FAQ

Q:Google 多快会索引 sitemap 里的新 URL? A:提交后 24-48 小时内会被发现。完整索引取决于站点权重——一般 3-14 天。

Q:Bing 也吃 sitemap ping 吗? A:吃;Bing Webmaster Tools 有自己的提交流程,加上 ping URL。

Q:小站需要 sitemap 吗? A:100 页以内靠内部链接通常够。但 sitemap 是廉价保险,能补发现盲区。

Q:sitemap 要包含图片吗? A:可选——图片 sitemap 对图片搜索有用,但普通页面索引不必须。等核心 sitemap 稳定了再加。

相关阅读

标签: #content-site #运营 #排查