Skip to the content
All posts

Crawling3 min read

The robots.txt mistakes that take a site out of search

robots.txt is a short file with a long reach. The mistakes that block a whole site, the ones that only look like they work, and how to check it.

robots.txt is a plain text file at the root of a site that tells crawlers which paths they may fetch. It is short, it rarely changes, and it is read before anything else. A mistake in it applies to every page at once.

The line that blocks everything

A staging robots.txt
User-agent: *
Disallow: /

This is the right file for a staging site and the wrong one for production. It reaches production the same way any file does: copied, promoted with a release, or served by a rule that was meant for another host. Crawlers stop fetching the site, and its pages fall out of search over time.

The opposite is one character away. An empty Disallow: allows everything.

Crawling is not indexing

A disallowed page is not fetched. It can still appear in search if other pages link to it, shown as a bare address without a description, because the crawler was never allowed to read it.

For the same reason, robots.txt is the wrong tool for removing a page. Use noindex on the page and leave it crawlable, so the instruction can be read. A noindex line inside robots.txt itself does nothing.

Groups do not add up

Rules are grouped by User-agent, and a crawler follows the most specific group that names it. It does not also follow the general one.

A common surprise
User-agent: *
Disallow: /admin/

User-agent: Googlebot
Disallow: /search/

Here Googlebot may crawl /admin/. Its own group replaced the general group, and that group only mentions /search/.

Quieter mistakes

  • Blocking scripts and styles. A crawler that renders pages needs the files the page loads. Disallowing /assets/ can leave it with a blank page.
  • The wrong case. Paths are case-sensitive: /Blog/ and /blog/ are different rules.
  • One file for every host. The file applies to the host it is served from. A subdomain needs its own.
  • A server error. If robots.txt itself answers with a 5xx, Google may treat the whole site as disallowed for a while.
  • No sitemap line. Not an error, but Sitemap: is the simplest way to tell every crawler where the list of pages is.

Checking it

  1. Keep the production file in the repository, apart from any staging one.
  2. After each deploy, fetch /robots.txt from the live host and compare it with the last version.
  3. Test the addresses that matter against the rules, for the crawlers that matter.

With Ranky

Ranky reads robots.txt on every scan. It reports a file that is missing, one that blocks the whole site, and any change to it, with the text before and after. It also shows which search and AI crawlers the file keeps out, and which line does it, and it flags the pages that robots.txt blocks.

The details are in Checks.

Catch the next bad deploy before search engines do

Start with one site, free. Every check, weekly scans, no card needed.