Robots.txt is a small text file that tells search engine bots which parts of your site they may crawl. One wrong line can stop Google from crawling your whole website, so it is worth understanding properly. This guide uses plain examples.
Free tools for this guide
- Robots.txt Generator: create a clean file in seconds
- Robots.txt Tester: check if a URL is allowed or blocked
- Robots.txt for WordPress: a safe starting file for WordPress
- AI Crawler Robots.txt Generator: rules for GPTBot, ClaudeBot and others
- Meta Robots Tag Generator: noindex and nofollow tags
Where it lives
The file must be at the root of the domain: https://yoursite.com/robots.txt. A robots.txt in a subfolder is ignored. Each subdomain (for example shop.yoursite.com) needs its own file.
The four rules you need
- User-agent: which bot the rules apply to.
*means all bots. - Disallow: a path the bot should not crawl.
- Allow: an exception inside a disallowed folder.
- Sitemap: the full URL of your XML sitemap.
Google also understands * as a wildcard and $ for “ends with”. It ignores Crawl-delay.
A safe WordPress example
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/
Sitemap: https://yoursite.com/sitemap_index.xml
This keeps bots out of the admin area and internal search results, while leaving everything else open.
An online store example
User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/
Disallow: /*?orderby=
Disallow: /*?filter_
Sitemap: https://yourstore.com/sitemap_index.xml
Blocking sort and filter URLs stops Google wasting crawl time on thousands of near-duplicate pages.
The biggest misunderstanding
Robots.txt controls crawling, not indexing. If other sites link to a blocked URL, Google can still index it, usually with no description. To keep a page out of search results, allow crawling and add a noindex meta robots tag instead. Google has to crawl the page to see that tag.
Common mistakes
Disallow: /left on after launch. Developers often block the whole site on staging, then forget. Also check that WordPress “Discourage search engines” is turned off.- Blocking CSS and JavaScript. Google needs them to render your pages and judge mobile-friendliness.
- Using robots.txt to hide private pages. The file is public, so it can point people straight to them. Use passwords instead.
- Typos in paths. Rules are case-sensitive:
/Blog/and/blog/are different. - Forgetting the sitemap line. It is an easy way to help bots find your pages.
How to test your file
- Paste your rules and a few important URLs into the Robots.txt Tester.
- Make sure your home page, main service pages and blog posts show as allowed.
- In Google Search Console, open Settings and check the robots.txt report for fetch errors.
- Use URL Inspection on a key page to confirm “Crawl allowed: Yes”.
What about AI bots?
You can add separate rules for AI crawlers such as GPTBot, ClaudeBot and PerplexityBot. Read our llms.txt and AI crawler guide before you block them, because for most businesses being cited by AI is useful visibility.
Frequently asked questions
What does robots.txt do?
Robots.txt tells crawlers which paths of a site they may crawl. It controls crawling, not indexing.
Can robots.txt remove a page from Google?
No. To keep a page out of search results, allow crawling and add a noindex tag instead.
Should I block AI crawlers in robots.txt?
It depends on your goals. Blocking AI search crawlers can stop your content from being cited in AI answers, so many sites allow search bots and only limit training bots.



