Technical SEO

What is robots.txt?

Short answer

robots.txt is a text file at the root of your site that tells crawlers which paths they shouldn't crawl. It controls crawling, not indexing: a blocked page can still appear in Google if other sites link to it.

robots.txt, defined

robots.txt is a plain-text file at the root of a website (yoursite.com/robots.txt) that tells crawlers which parts of the site they may or may not request. It follows the Robots Exclusion Protocol, which has been used since 1994 and became an official internet standard (RFC 9309) in 2022.

Every major search engine checks robots.txt before crawling a site. Most reputable AI crawlers do too. It's one of the smallest files on your site and one of the easiest to get catastrophically wrong.

What robots.txt looks like

A robots.txt file is a set of groups. Each group starts with one or more User-agent lines naming the crawler, followed by rules:

  • User-agent: which crawler the rules apply to. An asterisk means all crawlers.
  • Disallow: a path the crawler shouldn't request.
  • Allow: an exception inside a disallowed path.
  • Sitemap: the full URL of your XML sitemap. This can appear anywhere in the file.

A typical B2B site might disallow its admin area, internal search results and cart pages for all crawlers, and list its sitemap.

The most important thing to know

robots.txt controls crawling, not indexing. If you disallow a page, Google won't fetch it, but it can still index the URL if other pages link to it, usually showing it without a description.

To keep a page out of search results, use a noindex meta tag or header instead, and make sure the page is not blocked in robots.txt, otherwise Google can't see the noindex.

This is the most common robots.txt mistake I see: trying to remove pages from Google by blocking them, which leaves them indexed and stuck.

What robots.txt is good for

  • Keeping crawlers out of infinite or low-value URL spaces: filters, sort orders, calendars, internal search results.
  • Protecting server resources on very large sites.
  • Focusing crawl on important pages, which matters on sites with tens of thousands of URLs. See crawl budget for SaaS sites.
  • Controlling which AI crawlers can access your content.
  • Pointing crawlers to your sitemap.

What robots.txt is not

  • Not security. The file is public, and badly behaved bots ignore it. Never use it to hide private content; use authentication.
  • Not a removal tool. Use noindex, or the removals tool in Google Search Console for urgent cases.
  • Not a way to fix duplicate content. Use canonical tags and redirects.

Common mistakes

  1. Leaving "Disallow: /" from a staging site. This blocks the entire site. It happens surprisingly often after launches and migrations.
  2. Blocking CSS and JavaScript files. Google needs them to render the page and judge its layout.
  3. Blocking pages you want deindexed, as explained above.
  4. Case and path errors. Paths are case-sensitive, and a missing slash can block more than intended.
  5. Conflicting groups. A crawler follows only the most specific group matching its name, not the general one too.
  6. Blocking AI crawlers by accident with overly broad rules copied from a template.

robots.txt and AI crawlers

AI companies run their own crawlers, and many identify themselves with distinct user agents. Some examples:

  • GPTBot: OpenAI's crawler for collecting training data.
  • OAI-SearchBot: OpenAI's crawler for ChatGPT search results.
  • ChatGPT-User: fetches pages when a user asks ChatGPT to visit them.
  • PerplexityBot: Perplexity's crawler.
  • ClaudeBot: Anthropic's crawler.
  • Google-Extended: a token that controls whether Google uses your content for Gemini training and grounding. It doesn't affect Google Search or AI Overviews, which use Googlebot.

This lets you choose: for example, allow search-related bots so you can be cited in AI answers, while blocking training crawlers if you prefer. For most B2B companies that want to be recommended by AI assistants, blocking all AI crawlers works against AI search visibility. Decide on purpose, not by accident.

How to test your robots.txt

  1. Open yoursite.com/robots.txt and read it line by line.
  2. Check the robots.txt report in Search Console, which shows the version Google fetched and any errors.
  3. Use the URL Inspection tool on important pages to confirm they're not blocked.
  4. Crawl your site with a tool that respects robots.txt and see which URLs are excluded.
  5. After any launch or migration, check it again. It takes a minute and can save months.

A sensible default

For most small and mid-size B2B sites, a short file is best: allow everything, disallow genuinely useless areas like admin and internal search, and list the sitemap. Complex rules belong on large sites with a clear crawl problem to solve, ideally after looking at server logs.

Bottom line

robots.txt is a simple instruction file for crawlers. Use it to steer crawlers away from waste, never to hide or deindex pages, and check it after every deploy that touches site configuration. It's one of the first files I check in any SEO audit and a core part of technical SEO.

Answered by Federico Martinez, SEO & AI Search Strategist · 4 min read. See all SEO questions

Want this sorted for your site?

Tell me what you're working on and I'll suggest a plan.

Federico Martinez

Related questions