A robots.txt file is a plain text file at the root of a website that tells search engine crawlers which URLs they may crawl. It uses 4 rules, Google ignores files over 500 KiB, and it cannot keep a page out of search results.
Key facts
- A robots.txt file lives at the root of a site, for example example.com/robots.txt, and each site has only one.
- Google supports 4 rules: User-agent, Disallow, Allow and Sitemap.
- Google ignores everything past 500 KiB in a robots.txt file.
- Google caches robots.txt for up to 24 hours.
- A page blocked in robots.txt can still appear in search results, without a description.
What a robots.txt file does
A robots.txt file manages crawler traffic. Its main job is to keep crawlers away from unimportant or similar pages, so they spend their crawl budget on pages that matter. It also keeps media files and resource files out of search results when needed.
| Rule | What it does |
|---|---|
| User-agent | Names the crawler the rules apply to; * means all crawlers |
| Disallow | Lists paths the crawler must not access |
| Allow | Lists paths the crawler may access, even inside a blocked folder |
| Sitemap | Gives the full URL of the sitemap |
What a robots.txt file looks like
User-agent: Googlebot
Disallow: /nogooglebot/
User-agent: *
Allow: /
Sitemap: https://www.example.com/sitemap.xml
In this example Googlebot cannot crawl anything under /nogooglebot/, while all other crawlers may crawl the whole site. The sitemap line points crawlers to the sitemap.
Rules are case-sensitive for paths, so /File.asp and /file.asp are different URLs to a crawler. The # character starts a comment, and the * wildcard can stand in for any part of a path.
What robots.txt cannot do
A robots.txt file is a request, not a lock. Googlebot and other respectable crawlers obey it, but bad crawlers may ignore it.
A blocked page can still be indexed if other sites link to it, because Google may show the URL without a description. To hide a page from Google, use a noindex tag or password-protect the page.
- Do not block CSS and JavaScript files that Google needs to render a page.
- Do not use robots.txt to hide private content, since anyone can read the file.
- Do not place the file in a subdirectory, where crawlers never look for it.
- Do not add a crawl-delay rule, which Google does not support.
How Google handles a missing or broken file
Google checks robots.txt before crawling a site, and the HTTP status of the file changes what it does next.
| HTTP status | What Google does |
|---|---|
| 2xx success | Reads and follows the file |
| 3xx redirect | Follows up to 5 redirect hops |
| 4xx error | Treats it as if no robots.txt file exists |
| 5xx error | Stops crawling for 12 hours, then uses the cached copy for up to 30 days |
How to create and test one
- Create a plain text file named robots.txt in any text editor, saved as UTF-8.
- Add your rules, one per line, starting each group with a User-agent line.
- Upload the file to the root of your site, not a subdirectory.
- Open example.com/robots.txt in a browser to check it loads, then test it in the robots.txt report in Google Search Console.
For a full SEO checklist, see SEO checklist.
FAQ
What is a robots.txt file?
A plain text file at the root of a website that tells search engine crawlers which URLs they may crawl. It uses 4 rules: User-agent, Disallow, Allow and Sitemap.
Where does a robots.txt file go?
At the root of your site, for example example.com/robots.txt. It cannot sit in a subdirectory, and each site has only one.
Can robots.txt hide a page from Google?
No. A blocked page can still appear in search results without a description if other sites link to it. Use a noindex tag or password protection to hide a page.
What happens if robots.txt returns a 404?
Google treats a 404 as if no robots.txt file exists, so it assumes there are no crawl restrictions.
How big can a robots.txt file be?
Google ignores everything past 500 KiB. Keep the file small by grouping similar paths under one directory.
Sources
- Google Search Central: Robots.txt Introduction and Guide (checked 23 Nov 2026)
- Google Search Central: Create and Submit a robots.txt File (checked 23 Nov 2026)
- Google Search Central: How Google Interprets the robots.txt Specification (checked 23 Nov 2026)
