sitemap.xml 和 robots.txt 怎么写?技术 SEO 基础

sitemap.xml 和 robots.txt 怎么写?

这两个文件是技术 SEO 的地基,让搜索引擎顺利发现和抓取你的页面。

sitemap.xml:网站的目录

把网站所有需要被收录的页面列出来,提交到搜索引擎站长平台。

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://1iugf.com/</loc>
    <lastmod>2026-08-18</lastmod>
  </url>
  <url>
    <loc>https://1iugf.com/posts/what-is-seo/</loc>
    <lastmod>2026-08-18</lastmod>
  </url>
</urlset>

robots.txt:抓取规则

告诉搜索引擎哪些可以抓,哪些不可以。注意:它不阻止收录,只影响抓取

User-agent: *
Allow: /
Sitemap: https://1iugf.com/sitemap.xml

常见错误

小结

这两个文件 + 站长平台提交,就是”让搜索引擎知道你”的完整闭环。本站的 sitemap 和 robots 是自动生成的,你可以在 /sitemap.xml/robots.txt 看到效果。