Robots.txt: A Beginner's Guide With Examples
XUtilHub Team ·
A robots.txt file is a short text file that tells search engine crawlers which parts of your site they may visit. One wrong line can stop Google from crawling your entire website, so it's worth getting right.
Where it lives
Always at the root of the domain: https://example.com/robots.txt. Each subdomain needs its own file.
The basic syntax
User-agent: *
Disallow: /admin/
Disallow: /cart
Allow: /admin/public/
Sitemap: https://example.com/sitemap.xml
- User-agent says which crawler the rules apply to.
*means all. - Disallow blocks paths starting with that text.
- Allow makes an exception inside a blocked folder.
- Sitemap tells crawlers where your sitemap is.
Matching rules
| Rule | Blocks |
|---|---|
Disallow: /admin/ | Everything in the /admin/ folder |
Disallow: /search | /search, /search?q=x, /searching |
Disallow: /*.pdf$ | Every URL ending in .pdf |
Disallow: / | The entire site |
Disallow: (empty) | Nothing |
When Allow and Disallow rules conflict, Google follows the most specific (longest) matching rule.
What robots.txt can't do
It doesn't hide pages from search results. It stops crawling, not indexing. If other sites link to a blocked page, Google can still list the URL, just without a description. To keep a page out of search results, allow crawling and add a noindex robots meta tag instead.
It isn't security. The file is public, and badly behaved bots ignore it. Never use it to hide private areas; protect them with logins.
Common, costly mistakes
- Leaving
Disallow: /from a staging site after launch. It blocks everything. - Blocking CSS and JavaScript. Google needs them to render your pages and judge mobile-friendliness.
- Blocking a page and adding noindex. If Google can't crawl the page, it never sees the noindex.
- Wrong capitalisation. Paths are case-sensitive:
/Admin/and/admin/are different.
AI crawlers
Many sites now decide whether to allow AI training crawlers such as GPTBot (OpenAI), Google-Extended (Google's AI training control) and CCBot (Common Crawl). Each has its own user-agent name you can block or allow:
User-agent: GPTBot
Disallow: /
Create and test
Build a file with the robots.txt generator, then check exactly which URLs it allows or blocks for each crawler with the robots.txt tester. Make sure your file points to a sitemap; you can create one with the sitemap generator.
Tools mentioned in this article
Robots.txt GeneratorNEW
Create a robots.txt file in seconds: disallow paths, add your sitemap, and allow or block Googlebot, Bingbot and AI crawlers like GPTBot and ClaudeBot.
Robots.txt TesterNEW
Free robots.txt checker and validator. Fetch any site's robots.txt, find errors, and test whether Googlebot, Bingbot or AI crawlers can crawl your URLs.
XML Sitemap GeneratorNEW
Generate an XML sitemap by crawling your website (up to 500 pages) or from a list of URLs. Respects robots.txt and noindex. Download sitemap.xml instantly.