Guides · updated 23 Nov 2026
robots.txt and sitemap.xml explained
Two small files at the root of a website tell search engines where they may crawl and which pages exist. What each one does, what it can't do, and the mistakes that keep pages out of Google.
Most websites have two small files at the top level that are written for machines rather than people. robots.txt tells crawlers such as Googlebot which parts of the site they may visit. sitemap.xml lists the pages the owner would like search engines to know about. The Website panel of a Domain Statistics report shows whether a site has each one. This guide explains what they do, and what they can't do.
robots.txt: a request, not a lock
robots.txt is a plain text file at the root of a site, for example https://example.co.uk/robots.txt. The format is old, but it was only published as an internet standard, RFC 9309, in September 2022.
Two points about it surprise a lot of people:
- It is voluntary. Well-behaved crawlers read it and obey it. Badly behaved ones ignore it. RFC 9309 says plainly that the rules "are not a form of access authorization". Anything private needs a password, not a line in robots.txt.
- It is public. Anyone can read the file, so listing a secret folder in it is a good way to advertise that folder.
Google describes robots.txt as a way to manage crawler traffic, mainly "to avoid overloading your site with requests", and says it is "not a mechanism for keeping a web page out of Google" (Google's introduction).
How the file is written
The file is made of groups. Each group starts with one or more User-agent lines naming the crawler, followed by Disallow and Allow rules (Google's guide to writing one):
User-agent: *
Disallow: /basket/
Allow: /basket/help/
Sitemap: https://example.co.uk/sitemap.xml
Points to know:
- One file per host, at the root. A file in a subfolder is ignored. The file at
https://example.co.uk/robots.txtdoesn't coverhttps://shop.example.co.uk/or the plainhttp://version of the site, which need their own. - Paths are case-sensitive.
Disallow: /File.htmldoesn't block/file.html. - The most specific rule wins. When an
Allowand aDisallowboth match, crawlers use the one with the longer path. If they are the same length,Allowwins (RFC 9309). *is a wildcard in paths, andUser-agent: *means every crawler without a group of its own.- Save it as plain UTF-8 text. Google warns against word processors, which can add curly quotes and other characters crawlers don't understand.
What a missing or broken file means
A missing robots.txt is not an error. Under RFC 9309, if the server answers that the file doesn't exist (a 4xx status such as 404), crawlers may visit everything. A server error is treated very differently: if the file can't be fetched because of a 5xx error, crawlers must assume the whole site is off limits. A site whose robots.txt address returns errors can lose crawling entirely, so it's worth making sure that address gives either a file or a clean 404.
Crawlers may keep a copy of the file, but the standard says they shouldn't rely on a cached copy for more than 24 hours. A change can therefore take up to a day to be noticed.
The most damaging line in robots.txt is a single slash:
User-agent: *
Disallow: /
That blocks every compliant crawler from the whole site. It is often left behind when a site moves from a test server to the live one. A Domain Statistics report says "blocks all crawlers from the whole site" when it finds this.
Blocking crawling is not the same as hiding a page
If you want a page kept out of Google's results, robots.txt is the wrong tool. Google says a page blocked in robots.txt can still appear in results if other sites link to it, just without a description.
The right tool is a noindex rule, either as a robots meta tag in the page or as an X-Robots-Tag: noindex HTTP header for PDFs and other files. But Google can only see that rule if it is allowed to fetch the page. Google's noindex documentation says that if the page is blocked by robots.txt, "the crawler will never see the noindex rule, and the page can still appear in search results". Google also doesn't support noindex written inside robots.txt itself. The report's Website panel shows any robots meta tag or X-Robots-Tag header on the home page.
AI crawlers
Many site owners now use robots.txt to say whether their content may be used by AI systems. Each company publishes the user-agent token it honours. For Google, Googlebot controls crawling for Google Search, while a separate token, Google-Extended, controls whether content Google has crawled may be used to train future Gemini models and for grounding in Gemini Apps and Vertex AI. Google says Google-Extended "does not impact a site's inclusion in Google Search nor is it used as a ranking signal" (Google's list of crawlers). Other companies' tokens are listed in their own documentation, and only crawlers that choose to follow robots.txt will take any notice.
sitemap.xml: a list of pages you want found
A sitemap is an XML file listing the addresses on a site, usually at /sitemap.xml. It helps search engines find pages, especially on large or new sites with few links pointing in. Google's sitemap guide sets out the rules it follows:
- A single sitemap can hold at most 50,000 URLs or 50 MB uncompressed. Bigger sites split their list and use a sitemap index, a file that lists other sitemaps.
- Use full, absolute addresses (
https://example.co.uk/page/), not relative ones. - Google uses the
lastmoddate only if it is "consistently and verifiably" accurate, and it ignorespriorityandchangefreq. - A sitemap is "merely a hint". It doesn't guarantee that pages will be crawled or indexed.
There are two ways to tell search engines where it is: add a Sitemap: line with the full address to robots.txt, as in the example above, or submit it in Google Search Console's Sitemaps report, which also shows when Google last read it and any errors. Our guide to checking whether Google has indexed your site covers Search Console in more detail.
A sitemap doesn't have to be at /sitemap.xml. Some sites use another address and announce it in robots.txt instead. The report checks both places.
Checking your own site
- Open
/robots.txton your domain in a private browser window. Check there is noDisallow: /underUser-agent: *unless you really mean it. - Make sure nothing you want in search results is blocked, including the CSS and JavaScript files your pages need to display properly.
- Open your sitemap and check that the addresses use your real domain and
https://, not a test server or an old address. - Use the robots.txt report and Sitemaps report in Google Search Console to see what Google has read.
- Run a Domain Statistics lookup for a quick view of both files, the home page's robots directives and its redirects. The glossary has short definitions of robots.txt, XML sitemaps and noindex.
Details above are as published by the IETF and Google, checked in November 2026. Other search engines follow the same standard but may differ in the details.
Sources
- rfc-editor.org — RFC 9309, Robots Exclusion Protocol (Standards Track, September 2022): file at /robots.txt; the most specific (longest) match wins and allow wins a tie; a 4xx answer means crawlers may access anything, a server error means assume complete disallow; cached copies should not be used for more than 24 hours; parsing limit at least 500 KiB; not a form of access control
- developers.google.com — Google: robots.txt manages crawler traffic and is "not a mechanism for keeping a web page out of Google"; a blocked URL can still appear in results without a description; not all search engines support every rule
- developers.google.com — Google: how to write robots.txt – one file at the root of each protocol, host and port; UTF-8; User-agent, Disallow, Allow and Sitemap lines; rules are case-sensitive; * wildcard; the robots.txt report in Search Console
- developers.google.com — Google: noindex only works if the page is not blocked by robots.txt; noindex in robots.txt is not supported; X-Robots-Tag header for PDFs and other files
- developers.google.com — Google's crawlers: the Googlebot token controls Google Search crawling; Google-Extended controls use for Gemini training and grounding and does not affect inclusion or ranking in Google Search
- developers.google.com — Google: sitemap limits of 50,000 URLs or 50 MB uncompressed, sitemap index files, absolute URLs, lastmod used only if consistently accurate, priority and changefreq ignored, a sitemap is "merely a hint"
- support.google.com — Search Console Sitemaps report
Facts checked on 23 Nov 2026. Rules and figures change — check the source if it matters.