robots.txt

Every website can have a robots.txt file at the root of its domain, such as example.co.uk/robots.txt. Crawlers like Googlebot read it before they visit, and it tells them which parts of the site to leave alone. It's a request rather than a lock, so well-behaved crawlers follow it and others may not.

How a robots file blocks a folder

Each group of rules starts with a User-agent line, which says which crawler it's for. An asterisk means every crawler. Below it, Disallow lines list the paths that crawler shouldn't request, such as /basket/ or /search/.

Anything that isn't disallowed is open to crawl, so a shop might block its basket and internal search pages while leaving every product page open. A Sitemap line at the end can point crawlers to your XML sitemap as well.

You can also write rules for one crawler, such as Googlebot or an AI crawler, by giving it a group of its own. Many sites now do this to decide which AI tools can read their pages.

What a robots file can't do

Blocking a page in robots.txt stops Google from crawling it, but not from indexing it. If other pages link to a blocked address, Google can still list it in the results, usually without a description.

To keep a page out of search results, let Google crawl it and add a noindex tag instead. For anything private, such as customer accounts or staff areas, a password is the only safe option.

Common robots file mistakes

The most damaging one is a stray Disallow: /, often left over from a test site, which asks crawlers to skip the whole website. Blocking CSS or JavaScript files is another, as it can stop Google from seeing a page the way visitors do.

When two rules match the same address, Google follows the more specific one. It's worth testing any change in Search Console before relying on it.

Bird's own robots files

Our live site and the new version we're building each have a robots file, and our free checker reads them the way Google does.

  1. bird.co.uk/robots.txt
    User-agent: *Disallow: /wp-content/uploads/quformSitemap: https://bird.co.uk/sitemap_index.xml
    The live file on bird.co.uk

    Our current site's file is written by the Yoast plugin. It lets every crawler in, asks them to skip the folder a form plugin uses for uploads, and points them to the sitemap.

  2. The new site's robots.txt
    // Allow crawling to see noindex; robots exclusion alone does not prevent indexing. return new Response(`User-agent: *\nAllow: /\n
    Open to crawl so noindex can be read

    The new site allows every path on purpose. While it's being built, its pages carry a noindex tag, and Google can only see that tag if it's allowed to crawl the page.

  3. Our noindex checker
    matched.sort( (a, b) => b.length - a.length || Number(b.allow) - Number(a.allow), );
    The longest matching rule wins

    Our free noindex checker reads the site's robots file as part of its check. When more than one rule matches, it picks the longest. An Allow beats a Disallow of the same length, which is how Google settles a tie.

More technical SEO glossary terms

These technical SEO glossary terms cover crawling, indexing, redirects, sitemaps, structured data and page speed. Each definition shows the idea in a diagram and gives a practical example, so developers, marketers and site owners can talk about the same fix in the same words.