robots.txt and sitemap.xml: technical SEO guide | POLPROG Skip to content

robots.txt and sitemap.xml: a complete technical SEO guide

robots.txt and sitemap.xml solve two different technical SEO problems. The first controls which URLs crawlers may fetch, while the second helps search engines discover important URLs and their metadata. Problems begin when robots.txt is used to block indexing or when a sitemap contains redirects, duplicates and noindex URLs. A solid setup combines crawl control, consistent canonical URLs, accurate sitemaps and Search Console monitoring.

Published Written by Reading time 20 min read

robots.txt and sitemap.xml solve two different technical SEO problems. The first controls which URLs crawlers may fetch, while the second helps search engines discover important URLs and their metadata. Problems begin when robots.txt is used to block indexing or when a sitemap contains redirects, duplicates and noindex URLs. A solid setup combines crawl control, consistent canonical URLs, accurate sitemaps and Search Console monitoring.

On this page
  1. 1robots.txt and sitemap.xml solve different problems
  2. 2robots.txt location and scope
  3. 3Basic robots.txt syntax
  4. 4Rule matching: specificity, case and wildcards
  5. 5robots.txt is not an indexing control
  6. 6robots.txt errors, HTTP status codes and caching
  7. 7What sitemap.xml is for
  8. 8Supported sitemap formats
  9. 9Sitemap and sitemap-index limits
  10. 10Which URLs belong in a sitemap
  11. 11`<lastmod>`, `<priority>` and `<changefreq>`
  12. 12How to submit a sitemap to Google
  13. 13Multilingual sites and specialized sitemaps
  14. 14Common technical SEO mistakes
  15. 15Deployment checklist for robots.txt and sitemap.xml

robots.txt and sitemap.xml solve different problems

MechanismPurposeScopeMain effect
robots.txtControl crawlingCrawler pathsDoes not guarantee deindexing
sitemap.xmlDiscover and signal important URLsURL list and metadataHint, not an indexing guarantee
noindexExclude from the indexSpecific URL or resourceWorks after a crawler reads it
rel="canonical"Declare a preferred duplicate versionSpecific URL or resourceStrong signal, not an absolute directive

robots.txt is part of the Robots Exclusion Protocol and tells crawlers which paths they may or may not fetch. It is not authentication or a privacy control. RFC 9309 explicitly states that robots rules are not access authorization. [4]

A sitemap provides search engines with information about pages, videos and other files that you consider important, including relationships and metadata. Google uses sitemaps to discover and crawl content more efficiently. [6]

The mechanisms are not interchangeable. robots.txt controls crawling permission, while sitemap.xml helps with discovery and prioritization of important URLs.

robots.txt location and scope

The file must be named `robots.txt` and placed at the root of the host, such as `https://example.com/robots.txt`. A robots file in a subdirectory does not control the whole site. [2][4]

Its scope is tied to protocol, host and port. Rules from `https://example.com/robots.txt` do not automatically apply to `http://example.com`, `https://m.example.com` or another port. [2]

The file should be UTF-8 plain text. Google enforces a 500 KiB size limit and ignores content beyond that limit. [3]

Basic robots.txt syntax

User-agent: *
Disallow: /admin/
Allow: /admin/public/

Sitemap: https://example.com/sitemap.xml

Google supports the fields `user-agent`, `allow`, `disallow` and `sitemap`. Fields such as `crawl-delay` are not supported by Google. [3]

`user-agent` selects the crawler. `disallow` blocks a path from crawling, while `allow` can open a more specific path inside a blocked area. [3]

The `sitemap` field takes a fully qualified sitemap or sitemap-index URL. Multiple `Sitemap` lines are allowed. [2][3]

Rule matching: specificity, case and wildcards

Google applies the most specific matching rule based on path length. If `allow` and `disallow` rules are equally specific, Google uses the less restrictive rule, which is `allow`. [3][4]

Path values in `allow` and `disallow` are case-sensitive. `/Folder/` and `/folder/` can therefore behave differently. [3]

Google supports `*` as a wildcard for zero or more characters and `$` as an end-of-URL marker. For example, `Disallow: /*.pdf$` can match URLs ending in `.pdf`. [3]

robots.txt is not an indexing control

A URL blocked in robots.txt may still appear in Google Search if Google discovers it from links elsewhere. Google may know the URL even though it cannot crawl the page content. [1][3]

To exclude a page from search results, use `noindex` in a robots meta tag or `X-Robots-Tag`. Google must be able to crawl the resource to see that rule. Blocking it in robots.txt at the same time can prevent Google from reading the `noindex`. [5][16]

Putting `noindex` directly in robots.txt is not supported by Google. [5]

robots.txt errors, HTTP status codes and caching

StatusGoogle behavior
2xxProcesses the file as robots.txt
3xxFollows redirects, at least 5 hops
4xx except 429Treats it as no robots.txt, so no crawl restrictions
5xx / networkMay pause crawling and use the last known good file

For `2xx`, Google processes the returned robots.txt. For redirects, Google follows at least five hops before it may treat the situation as if the file were missing. Most `4xx` responses except `429` are treated as no valid robots.txt, which means no crawl restrictions. [3]

For `5xx` or network failures, Google can initially stop crawling, then use the last known good robots.txt while retrying. Google documents separate behavior for the first 12 hours and the following 30 days. [3]

Google generally caches robots.txt for up to 24 hours, although the lifetime may change based on errors and `Cache-Control` headers. [3]

What sitemap.xml is for

A sitemap helps search engines discover important pages and files and can carry information about modification dates, localized versions, images, videos and news. [6][7]

Google notes that a small site of about 500 pages or fewer with comprehensive internal linking may not need a sitemap. Sitemaps are especially useful for large sites, new sites with few external links and sites with substantial media content. [6]

A sitemap does not replace internal linking and does not guarantee indexing.

Supported sitemap formats

Google supports XML, RSS, mRSS, Atom 1.0 and plain-text sitemaps as documented. XML is the most versatile because it supports extensions for images, video, news and localized versions. [7]

A text sitemap can list one absolute URL per line but cannot carry the richer metadata available in XML. RSS and Atom can be convenient when a CMS already publishes update feeds. [7]

Google states that it has no preference among the supported formats. The right choice depends on site architecture and the metadata you need to provide. [7]

Sitemap and sitemap-index limits

FileMaximum entriesMaximum sizeNote
Single sitemap50,00050 MBLimit is uncompressed; gzip is allowed
Sitemap index50,000 sitemaps50 MBLimit is uncompressed; gzip is allowed

A single sitemap is limited to 50,000 URLs or 50 MB uncompressed. If either limit is exceeded, split the sitemap into multiple files. [7][8]

A sitemap index can list up to 50,000 sitemaps and is also limited to 50 MB. More than one sitemap index can be used. [8]

Sitemaps can be gzip-compressed, but the size limit applies after decompression. [8]

Which URLs belong in a sitemap

Google recommends including the URLs you want to see in search results. Sitemap URLs should be fully qualified and absolute. [7]

If the same content is available at multiple URLs, the sitemap should usually contain the preferred canonical URL. Google treats sitemap inclusion as a weak canonicalization signal, weaker than redirects or `rel="canonical"`. [7][9]

A sitemap should not be a dump of every technically generated URL. Intentionally listing noindex URLs, 404s, redirects or duplicates sends a less coherent signal.

`<lastmod>`, `<priority>` and `<changefreq>`

Google ignores `<priority>` and `<changefreq>` values in sitemaps. There is no SEO benefit in building elaborate logic for those fields solely for Google. [7]

Google can use `<lastmod>` when it is consistently and verifiably accurate. The value should reflect the last significant change to page content, structured data or links. A copyright-year change alone is not considered significant. [7]

Updating `<lastmod>` on every deployment, regardless of page changes, weakens the usefulness of the signal.

How to submit a sitemap to Google

You can submit a sitemap through the Sitemaps report in Search Console, through the Search Console API, or reference it in robots.txt with `Sitemap: https://example.com/sitemap.xml`. [7][11][12]

Search Console is useful because the report exposes access and processing information and sitemap errors. [7][11]

Submitting a sitemap is only a hint. Google explicitly states that submission does not guarantee that the sitemap will be downloaded, used for crawling or that the listed URLs will be indexed. [7]

Multilingual sites and specialized sitemaps

For multilingual sites, Google allows `hreflang` relationships to be supplied in XML sitemaps. Each URL entry should reference all language or regional variants, including itself. [10]

Sitemaps can also be extended for images, videos and news. Google publishes separate requirements for each extension. [13][14][15]

For Google News, news metadata should cover recent articles. Google's current guidance says news sitemap metadata should be kept for articles from the last two days. [15]

Common technical SEO mistakes

One of the most serious mistakes is blocking a page in robots.txt while expecting Google to obey its `noindex`. If crawling is blocked, the indexing directive may never be seen. [5][16]

Another common issue is contradictory canonical signals, such as listing URL A in the sitemap while `rel="canonical"` points to URL B. Google recommends consistency between canonicalization methods. [9]

Sitemaps also become noisy when they contain unnecessary parameters, duplicates, redirects, error pages or faceted URLs that are not intended for search.

  • Do not use robots.txt as a replacement for `noindex`.
  • Do not block pages whose robots meta directives Google must read.
  • Do not put every generated URL into the sitemap.
  • Do not change `<lastmod>` without a meaningful page update.
  • Do not rely on `<priority>` or `<changefreq>` for Google.
  • Do not send conflicting sitemap and canonical signals.
  • Remember that subdomains and different protocols may need their own robots.txt.

Deployment checklist for robots.txt and sitemap.xml

Before release, inspect real HTTP responses rather than only repository files. robots.txt should return valid plain text, while the sitemap should return valid XML or another supported format. [2][7]

After publishing, submit the sitemap in Search Console, inspect the Sitemaps report and use URL Inspection for representative pages. During site migrations, Google recommends sitemaps as one mechanism that can help discover the new URLs. [11][17]

For larger sites, automation is valuable: generate sitemaps from the source of truth and validate URL status, canonical consistency, noindex state and meaningful `<lastmod>` values as part of the release process.

  • Is robots.txt available exactly at `/robots.txt`?
  • Do its rules apply to the intended protocol, host and port?
  • Is any important URL accidentally blocked?
  • Are noindex pages still crawlable?
  • Does the sitemap contain only absolute preferred URLs?
  • Is each sitemap below 50,000 URLs and 50 MB?
  • Does `<lastmod>` represent real meaningful updates?
  • Do canonical tags and sitemaps point to the same preferred URLs?
  • Are multilingual sitemap relationships correct?
  • Does Search Console report any sitemap fetch or processing errors?

The strongest technical SEO setup is simple and internally consistent. robots.txt should block only areas that crawlers genuinely should not fetch. sitemap.xml should contain URLs you want in search results, ideally canonical, accessible and indexable ones. Do not hide `noindex` behind robots.txt, and make `<lastmod>` reflect meaningful changes rather than every deployment. Finally, verify everything in Search Console and against real HTTP responses.

SEO Technical SEO robots.txt sitemap.xml Crawling Indexing Google Search Console Canonical hreflang Sitemaps

Frequently asked questions

Does robots.txt prevent indexing?

Not reliably. A crawl-blocked URL may still appear in search if Google discovers it elsewhere. Use noindex to exclude a URL from the index, and keep it crawlable so Google can read the rule. [1][5]

Can I put noindex in robots.txt?

Google does not support that. Use a robots meta tag or an X-Robots-Tag HTTP header instead. [5][16]

Does sitemap.xml guarantee indexing?

No. Sitemap submission is a hint and does not guarantee download, crawling or indexing. [7]

What are the sitemap limits?

A single sitemap is limited to 50,000 URLs and 50 MB uncompressed. Larger sets must be split and can be grouped in a sitemap index. [7][8]

Does Google use <priority> and <changefreq>?

No. Google says it ignores both values. [7]

Does Google use <lastmod>?

Yes, when it is consistently and verifiably accurate and reflects a meaningful page change. [7]

Must a sitemap be at the site root?

Google recommends the root. Without Search Console submission, sitemap scope is tied to the directory where it is hosted. [7]

Can a sitemap be hosted on another host?

Yes. Google supports cross-site submission in defined configurations, and a robots.txt Sitemap field can point to a fully qualified URL on another host. [3][7]

Does crawl-delay work for Google?

No. Google does not support the crawl-delay field in robots.txt. [3]

Should noindex or redirected URLs be in a sitemap?

If the sitemap is meant to represent URLs you want indexed, those entries create conflicting signals. Google recommends listing preferred canonical URLs. [7][9]

Can I have multiple sitemaps?

Yes. You can submit multiple sitemaps and indexes, and one sitemap index can list up to 50,000 sitemaps. [7][8]

Is a Sitemap line in robots.txt enough?

Google can discover the sitemap from robots.txt. Search Console is still useful because it reports sitemap access, processing and errors. [7][11]

Sources and references

  1. Google Search Central, robots.txt introduction12
  2. Google Crawling Infrastructure, Create and submit a robots.txt file1234
  3. Google Crawling Infrastructure, How Google interprets the robots.txt specification12345678910111213
  4. IETF RFC 9309, Robots Exclusion Protocol123
  5. Google Search Central, Block Search indexing with noindex12345
  6. Google Search Central, Learn about sitemaps123
  7. Google Search Central, Build and submit a sitemap12345678910111213141516171819202122
  8. sitemaps.org, Sitemap protocol12345
  9. Google Search Central, How to specify a canonical URL123
  10. Google Search Central, Localized versions of your pages
  11. Google Search Console Help, Sitemaps report1234
  12. Google Search Console API, Sitemaps: submit
  13. Google Search Central, Image sitemaps
  14. Google Search Central, Video sitemaps and alternatives
  15. Google Search Central, News sitemaps12
  16. Google Search Central, Robots meta tag and X-Robots-Tag specifications123
  17. Google Search Central, Site moves and migrations

Was this helpful?

Get new articles by email

One short email per new Learning article. No spam, unsubscribe in one click.

We only use your email to send new articles. No third-party sharing.

Back to Learning