What is robots.txt?
DEFINITION
robots.txt is a plain text file at the root of a website that tells search engine crawlers which paths they may or may not crawl.
robots.txt is a file located at yourdomain.com/robots.txt that follows the Robots Exclusion Protocol. It contains rules for crawlers, grouped by user agent. For example, "User-agent: *" followed by "Disallow: /cart/" asks all bots not to crawl the cart folder. You can also add a line like "Sitemap: https://example.com/sitemap.xml" to help crawlers find your sitemap.
Reputable crawlers such as Googlebot and Bingbot respect these rules, but the file is a request, not a security barrier. Malicious bots can ignore it, and anyone can read it.
Why robots.txt matters
It helps you keep crawlers away from low-value or endless URL spaces like internal search results, filter combinations or admin areas, so they spend more time on pages that matter. One wrong line can also block your entire site from being crawled, which is why it deserves careful review after every launch or migration.
Important limitation: crawling is not indexing
Disallowing a URL stops crawling, not indexing. If other sites link to a blocked page, Google can still index the URL without its content, sometimes showing it with no description. To keep a page out of search results, allow it to be crawled and add a noindex meta tag instead. For example, a thank-you page should use noindex, not a robots.txt disallow, if you truly want it hidden from search.
Best practices
- Test changes with the robots.txt report in Google Search Console before and after publishing.
- Block crawl traps such as internal search pages and infinite filter combinations.
- Reference your XML sitemap location inside the file.
- Keep the file short and commented so future editors understand each rule.
Common mistakes
- Leaving "Disallow: /" from a staging site in place after launch, which blocks everything.
- Blocking CSS and JavaScript files that Google needs to render your pages.
- Using robots.txt to hide sensitive or private content, which should be password protected instead.
Frequently asked questions
Does every website need a robots.txt file?
No. Without one, crawlers assume they may crawl everything, which is fine for many small sites. It becomes useful when you need to block crawl traps, manage crawling on a large site, or point bots to your sitemap. If you add one, double-check it does not block important pages.
How do I block AI crawlers with robots.txt?
Many AI companies publish user-agent names for their crawlers, such as GPTBot or Google-Extended. You can add a separate rule group for each one with "Disallow: /". Compliance is voluntary, and blocking Google-Extended does not affect normal Google Search crawling or ranking.
Can robots.txt remove a page from Google?
Not reliably. Blocking crawling can actually prevent Google from seeing a noindex tag, so the URL may stay indexed. Use a noindex tag, remove the page with a 404 or 410 status, or password-protect it. Search Console's removal tool offers a temporary hide while the fix takes effect.
Need help with this?
Référencement naturel (SEO) by VYZEON — Soyez trouvé en premier — sur chacun de vos marchés.
Fixed packages from $149/mo. Written scope, no surprises.
