大网数据广告活动
网站运营与故障问答

Should I add links to the Sitemap that are disallowed in robots.txt?

· 52CE 我爱测

My robots.txt contains the line Disallow: /search.php . Shall I nevertheless include http://example.com/search.php into my sitemap?

问题原文

原帖链接 · anpami · CC BY-SA 4.0

My robots.txt contains the line Disallow: /search.php.

Shall I nevertheless include http://example.com/search.php into my sitemap?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

You should not add URLs to your sitemap unless you want them crawled and indexed. If a URL is disallowed, non-canonical, or redirecting, it doesn't belong in your XML sitemap.

Google uses your XML sitemap as a list of pages that it should crawl. When you include non-crawlable pages in your XML sitemap Google will complain about them in Google Search Console. You would get the warning "Sitemap Contains Blocked Resources."

For further reading see my answer to How should I choose which URLs I want indexed to include in my sitemap?

You are correct to disallow search because Google doesn't want to index other search results. It is bad user experience for users to click from Google search result to your site search results. Google may penalize sites that allow their site search results to be crawled and indexed. See Matt Cutts: Search results in search results.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-07-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。