webzod
account

Fix the syntax of robots.txt

hygiene.robots.invalid · effort: minutes

Why it matters

A robots.txt that is really an html page, has rules before any User-agent line, or misspells a directive is partly or wholly ignored by crawlers. Rules you meant to apply then do nothing.

The fix

  1. Open https://example.com/robots.txt. If it shows an html page (a 404 page or your single-page app), the real file is missing and a catch-all rule is answering; add a static robots.txt that is served before that rule.
  2. Start every group with a User-agent line, followed by its rules. Spell directives exactly as Allow, Disallow and Sitemap, each on its own line, with comments starting with a
  3. Save the file as UTF-8, then test it again, for example with the robots.txt report in Google Search Console.
robots.txt
User-agent: *
Disallow: /search/
Allow: /

# Keep the next line only if the sitemap exists at this address
Sitemap: https://example.com/sitemap.xml

The examples use example.com. Replace it with your own domain.

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.