Skip to content

Writing robots.txt that works

Start with User-agent: * and Allow: /, add Sitemap:, block only what must be blocked, and verify with the robots tester.

robots.txt that protects without hiding

  1. Default to allow

    User-agent: * followed by Allow: / is the safe default. Then add Disallow: for specific paths.

  2. One sitemap per line

    Sitemap: can be repeated. List every sitemap and sitemap-index.

  3. Block only admin and search

    /admin/, /search/, /*?s= are the safe blocks. Blocking the whole / is never right.

  4. Test with Search Console

    The "robots.txt tester" in Search Console validates the syntax and simulates a fetch. Use it before every deploy.

  5. Never block the sitemap

    A Disallow: /sitemap.xml blocks the sitemap itself. If a rule blocks sitemaps, the crawler cannot discover URLs.