Guide

robots.txt explained: what it can and cannot do

Reviewed 22 November 2026 · 7 min read · Written and maintained by Toolnexo

A robots.txt file is a short text file that tells crawlers which parts of your site they may fetch. It is simple to write and easy to get wrong in ways that quietly cost traffic. It is also widely misunderstood: it is a polite request, not a security control, and it does not remove pages from search results. This guide explains how the format works, what the common rules do, how to handle AI crawlers, and the mistakes worth avoiding. You can build and check a file with the robots.txt generator on this site, which works entirely in your browser.

The basics

The file must be named robots.txt and served from the root of the host, for example https://example.com/robots.txt. Crawlers do not look in sub-folders, and a subdomain such as blog.example.com needs its own file. The format was standardised as RFC 9309 in 2022, and the major search engines follow it.

The file is made of groups. Each group starts with one or more User-agent lines naming the crawlers it applies to, followed by Allow and Disallow rules. A Sitemap line can appear anywhere and is independent of the groups.

  • User-agent: * means every crawler that has no more specific group.
  • Disallow: /admin/ asks crawlers not to fetch any URL that starts with /admin/.
  • Allow: /admin/public/ carves an exception out of a broader Disallow.
  • An empty Disallow: line means nothing is blocked.
  • Sitemap: https://example.com/sitemap.xml tells crawlers where your sitemap is.

Which rule wins

When several rules match a URL, the most specific one wins, meaning the one with the longest matching path. If an Allow and a Disallow match with equal length, the Allow is used. So Disallow: /shop/ together with Allow: /shop/sale/ blocks the shop except the sale pages.

Most major crawlers also understand two wildcards. The * matches any run of characters and $ marks the end of the URL, so Disallow: /*.pdf$ blocks addresses ending in .pdf. Each crawler follows only the single group that best matches its name, and does not add the rules from the * group on top, so a group for Googlebot must repeat any rules from the * group that you still want applied to it.

What robots.txt does not do

It is not a lock. Compliant crawlers follow it; badly behaved ones ignore it. Because the file itself is public, listing a private path in it also tells everyone the path exists. Never use robots.txt to protect sensitive content. Use authentication.

It also does not remove pages from search. A blocked URL can still be listed, usually without a description, if other sites link to it. To keep a page out of results, leave it crawlable and use a noindex meta tag or an X-Robots-Tag header. If you block the page in robots.txt, the crawler never sees the noindex instruction. Google stopped supporting noindex lines inside robots.txt in 2019.

AI crawlers

Many sites now add groups for AI-related crawlers. Common tokens include GPTBot, ChatGPT-User and OAI-SearchBot from OpenAI, ClaudeBot from Anthropic, CCBot from Common Crawl, PerplexityBot and Applebot-Extended. Google-Extended is a token that controls whether Google may use your content for its generative AI products; blocking it does not affect your appearance in Google Search.

Each of these is blocked with a group of its own, for example User-agent: GPTBot followed by Disallow: /. The generator has a button that adds the common ones. Remember that this is a request. The companies publish these tokens and say they honour them, but robots.txt cannot stop a crawler that chooses not to comply, and blocking a crawler that powers a search or answer product may reduce how often your pages are surfaced there.

Mistakes that cost traffic

  • Leaving Disallow: / from a staging site on the live site, which blocks everything.
  • Blocking CSS, JavaScript or image folders that pages need to render, which can make pages look broken to Google.
  • Putting the file in the wrong place or serving it with an error; a server error on robots.txt can pause crawling.
  • Relying on robots.txt to hide private pages or to remove a page that is already indexed.
  • Expecting Crawl-delay to slow Google, which ignores it. Bing and some other crawlers do honour it.
  • Letting the file grow very large; Google reads only the first 500 KiB.

Before you upload

  • Check that no rule blocks pages you want to rank.
  • Add your sitemap URL so crawlers can find every page.
  • Save the file as plain text and upload it to the site root.
  • Open /robots.txt in a browser to confirm it loads.
  • Test important URLs with the robots.txt report in Google Search Console after you deploy.
Tools in this guide

Put it into practice

How this guide is maintained

This page is reviewed when the related tools change. It describes what the published tools actually do: the tools run in your browser tab, so your files stay on your device. If you find something inaccurate, email [email protected] and it will be corrected.

Keep reading

Other guides

All guides →