robots.txt is a text file at the root of your site (example.com/robots.txt) that tells crawlers which paths they may or may not crawl. It uses User-agent, Disallow and Allow rules, and can list your sitemap. It controls crawling, not indexing — to keep a page out of search results, use a noindex tag instead and let crawlers see it.
robots.txt is one of the smallest files on your website and one of the easiest to get badly wrong. A single misplaced line can tell search engines to ignore your entire site. Fortunately, most sites only need a few simple rules — and knowing what robots.txt can and cannot do prevents most mistakes.
The key thing to remember: robots.txt controls crawling, not indexing. It asks well-behaved bots not to visit certain URLs, but it is not a security tool and does not hide pages from search results on its own.
robots.txt syntax
| Directive | Meaning |
|---|---|
| User-agent | Which crawler the rules apply to (* means all) |
| Disallow | Path the crawler should not crawl |
| Allow | Exception inside a disallowed path |
| Sitemap | Full URL of your XML sitemap |

Recommended robots.txt for WordPress
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://example.com/sitemap_index.xml
Do not block CSS, JavaScript or image folders — Google needs them to render your pages.
Managing AI crawlers
# Allow AI search crawlers, block model-training crawlers (example)
User-agent: OAI-SearchBot
Allow: /
User-agent: GPTBot
Disallow: /
User-agent: Google-Extended
Disallow: /
Blocking Google-Extended does not affect Google Search rankings. Learn more in what is GEO.

Common robots.txt mistakes
Disallow: /left on a live site — blocks crawling of everything (often left from development).- Using robots.txt to hide pages from Google — blocked pages can still be indexed from links; use noindex.
- Blocking CSS/JS — prevents proper rendering and evaluation.
- Wrong file location or case — it must be at the root and named exactly robots.txt.
- Blocking pages that carry a noindex tag — Google cannot see the noindex if it cannot crawl the page.
How to test robots.txt
- Open the fileVisit yourdomain.com/robots.txt.
- Check Search ConsoleThe robots.txt report shows the version Google fetched and any errors.
- Inspect URLsURL Inspection tells you if a URL is blocked by robots.txt.

Check your robots.txt in two minutes
- Open itVisit yourdomain.com/robots.txt.
- Look for “Disallow: /”Under “User-agent: *”, this blocks your whole site — remove it unless intended.
- Check important foldersMake sure CSS, JavaScript and images are not blocked.
- Confirm the sitemap lineAdd “Sitemap: https://yourdomain.com/sitemap.xml”.
- Test in Search ConsoleUse the robots.txt report to check for errors.
robots.txt vs noindex vs password protection
| Goal | Use |
|---|---|
| Reduce crawling of low-value URLs (filters, internal search) | robots.txt Disallow |
| Keep a page out of search results | noindex meta tag (and allow crawling) |
| Keep content private | Password protection or login |
| Remove an outdated URL | Redirect or 404/410, plus Search Console removal if urgent |
Warning: Many staging sites are launched with “Disallow: /” still in place. Always check robots.txt immediately after a redesign or migration.
Related: XML sitemaps, website not indexed and technical SEO.
Frequently asked questions
Does robots.txt stop a page from being indexed?
No. It only blocks crawling. A blocked page can still appear in results if other sites link to it. Use a noindex tag to prevent indexing.
Where do I put robots.txt?
In the root directory of your domain, so it is available at yourdomain.com/robots.txt.
Does WordPress create robots.txt automatically?
WordPress generates a virtual robots.txt if no physical file exists, and SEO plugins let you edit it.
Should I block AI crawlers in robots.txt?
It depends on your goals. You can block training crawlers while allowing AI search crawlers that can send you visitors.
Can I block specific bots with robots.txt?
Yes, by naming their user agent. Well-behaved bots follow the rules; malicious bots may ignore robots.txt.
Is robots.txt case-sensitive?
Paths are case-sensitive. The file name must be lowercase robots.txt at the root of your domain.
Do I need robots.txt if I do not block anything?
It is optional, but a simple file with your sitemap location is helpful and avoids 404 errors when bots request it.
Further reading: Google Search Central documentation.





