sitemap 与 robots.txt
robots.txt 放在网站根目录,告诉爬虫「哪里不要抓」;sitemap.xml 则是递给搜索引擎的页面清单,「这些页面请务必收录」。两者配合:后台与重复页面屏蔽,核心内容主动提交。
新站或内容更新频繁的站,把 sitemap 地址提交到搜索资源平台(百度站长 / Google Search Console),能明显加快收录。
本节要点robots.txt 管抓取、sitemap 管收录,一个都不缺;屏蔽后台、搜索结果页等无价值路径;改版后及时更新 sitemap。
代码
robots.txt(网站根目录):
User-agent: *
Disallow: /admin/
Disallow: /search?
Allow: /
Sitemap: https://example.com/sitemap.xml
sitemap.xml(核心页面清单):
<urlset>
<url><loc>https://example.com/</loc></url>
<url><loc>https://example.com/blog/seo-title-tags</loc></url>
</urlset>



