Discuss project

Sitemap.xml and robots.txt: what belongs in each

Sitemap.xml and robots.txt solve different problems and get confused constantly. What belongs in your sitemap, what to block in robots.txt and which mistakes cost you indexing.

Vladislav KrivorutskoAugust 16, 20268 min read
Contents

TL;DR - key points

  • Robots.txt controls crawling, not indexing: a page blocked there can still show up in search results — without a description and outside your control
  • Sitemap.xml is not a list of every URL on the site, it is a list of pages you consider worth indexing: 200 only, canonical only, indexable only
  • The most expensive mistake is blocking a page in robots.txt while it carries noindex or canonical: Google never reads the directive and the page stays indexed
  • A sitemap does not make Google index a page, it only speeds up discovery — noticeable on new sites and large catalogues, close to irrelevant on a 30-page site
  • Check both files with Search Console reports, not by eye: the Pages report filtered by blocking reason, and the Sitemaps report with its discovered-URL count

The short answer

Robots.txt controls crawling: it tells a crawler which addresses not to fetch. Sitemap.xml controls discovery: it lists the pages you want a search engine to know about. Neither file controls indexing directly — that is handled by the noindex meta tag, canonical and the quality of the page itself.

From this follows the main practical rule: a page you want out of search results must not be blocked in robots.txt. Otherwise the crawler never reads the noindex and the page stays in the index — just without a description.


What robots.txt actually does

Robots.txt sits at the domain root (https://site.ee/robots.txt) and is read before pages are crawled. Inside is a set of rules along the lines of "this crawler does not go here".

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /*?sort=
Disallow: /cart

Sitemap: https://site.ee/sitemap.xml

What matters here:

  • It is a request, not protection. Major search engines respect it, plenty of scrapers do not. Blocking private data with robots.txt is pointless: the file is public, so you are effectively publishing a list of the addresses you consider sensitive.
  • A blocked page can stay in search results. If external links point to it, Google knows the URL and may display it without a snippet. In Search Console this is "Indexed, though blocked by robots.txt".
  • Disallow does not remove what is already indexed. Quite the opposite: by blocking the crawl you take away Google's ability to see that the page changed or now carries noindex.
  • Rule order is not hierarchical. The most specific rule wins, not the first one from the top. Allow can override Disallow for a nested path.
  • Blocking CSS and JS is an obsolete practice. Google renders pages; block styles and scripts and you show it a broken layout.

One separate line is Sitemap: with the full absolute address of your sitemap. It is the only way to announce a sitemap to search engines where you have no webmaster console.


What belongs in sitemap.xml — and what does not

The most common misconception: a sitemap is "every URL on the site". It is not. It is a list of pages you consider worth indexing. Every URL in it is a statement to a search engine, and statements have to be consistent.

URL typeIn the sitemap?Why
Page returns 200 and is indexableYesThis is what a sitemap is for
Redirecting page (301/302)NoList the final address instead
404 or 410NoA direct signal the file is unmaintained
Page with noindexNoDirect conflict of signals
Non-canonical versionNoOnly the canonical address belongs here
URLs with sorting and filter parametersNoThey generate duplicates
Category paginationUsually noDiscovered through links
Tag and archive pagesDependsOnly if you genuinely need them in search
Language versionsYesEach with its own URL, tied together by hreflang

Format limits: up to 50,000 URLs and up to 50 MB uncompressed per file. Beyond that the sitemap is split and tied together by a sitemap index file. In practice only catalogues reach those limits, but splitting by page type — products, categories, articles — pays off earlier: Search Console then shows you exactly which type indexes badly.

On the optional tags: Google uses lastmod when it can be trusted. priority and changefreq are ignored, according to Google's own staff — do not spend time on them.


How these two files break indexing

Over the years I keep seeing the same short list.

1. A site-wide Disallow left over from development. The line Disallow: / travels from staging to production. Symptom: traffic collapses within a couple of weeks and "Blocked by robots.txt" grows in Search Console. It takes ten seconds to check — and it is the first thing I open when a site "just stopped showing up".

2. Disallow and noindex at the same time. Someone wanted a page out of search results, so they blocked it both in robots.txt and with a meta tag. The result is the opposite of the intent: noindex is never read, the page stays. The correct order is covered in the article on why Google is not indexing your pages.

3. A sitemap nobody has updated. Half the addresses return 404 and none of the new pages are there. Google gradually stops re-reading it and you lose the simplest channel for announcing new material.

4. Using the sitemap to force weak pages into the index. Adding a URL to a sitemap does not make the page worth showing. If Google sees it and passes, the problem is value or duplication, not discovery.

5. A relative address in the Sitemap directive. Only an absolute URL with protocol and domain works.

6. Different robots.txt on www and non-www, http and https. Formally these are different hosts and each reads its own file. This gets forgotten right after redirects are configured.

7. The sitemap itself blocked in robots.txt. Rarer, but it happens — usually when the sitemap lives in a blocked system folder.


What I check in practice

The sequence I run on any site before touching content:

  1. Open /robots.txt in a browser. It should return 200 and be short. A hundred-line file almost always contains years of accumulated junk.
  2. Scan for Disallow: / and anything blocking whole sections. Every such rule needs an explanation.
  3. Check a few important URLs with URL Inspection in Search Console: is crawling allowed, and which address does Google treat as canonical.
  4. Open the Sitemaps report: sitemap read, date recent, discovered URL count comparable to the real number of pages. A difference of several times over is worth digging into.
  5. Review the Pages report, specifically "Blocked by robots.txt" and "Discovered – currently not indexed". The first catches excess blocking; the second usually points at quality and structure rather than at these files.
  6. Compare the sitemap against reality: crawl the site and diff the sitemap URL list against the pages reachable by links. Differences in both directions are informative — what is missing from the sitemap is a candidate for orphan pages, and what is missing from the site is a dead address in the sitemap.

On the limits of all this: on a 20–40 page site with decent internal linking the sitemap decides almost nothing — Google finds everything through links within days. It becomes meaningful in two cases: a fresh domain with no external links, and a large catalogue where some pages sit deep. Expecting ranking gains from it is misplaced entirely: it is a discovery tool, not a ranking one.

If nothing changes within a day of editing robots.txt, that is normal. Google caches the file and does not re-read it on every crawl.


A working minimum for a normal site

The setup I start from on a service site or a small shop:

  1. Block in robots.txt only CMS system sections, the cart, checkout, the customer account and internal search results.
  2. Do not block CSS, JS, images or any page that is supposed to rank.
  3. Declare the absolute sitemap address with the Sitemap: directive.
  4. Generate sitemap.xml automatically through the CMS or a plugin, never by hand.
  5. Exclude from the sitemap non-canonical URLs, redirects, noindex pages and parameterised addresses.
  6. Submit the sitemap in Search Console and come back to the report a week later.
  7. For junk URLs already in the index, use noindex or canonical while crawling stays open — and only block them in robots.txt after a recrawl, if crawl budget justifies it.

If step 7 reveals that parameter and filter URLs multiply by the hundreds, two text files will not fix it: you need URL generation rules at the CMS level, which is web development. And once those junk addresses have pulled impressions onto themselves and compete with real pages, you are dealing with keyword cannibalization, which has to be untangled separately — usually as part of SEO work that rebuilds the structure.

Frequently asked questions

What is the difference between robots.txt and noindex?
Robots.txt tells a crawler not to fetch a page; noindex tells a search engine not to show it in results. They act at different levels: if a page is blocked in robots.txt, the crawler never reaches its content and never sees the noindex tag, so the page can stay indexed with a note that no description is available. For a page to reliably leave search results, it must be crawlable and return noindex.
Is a sitemap.xml required?
No, it is not mandatory, and a site indexes fine without one. Google states that a sitemap helps discover pages with few internal links and is useful on large or new sites. For a 20–30 page site with decent internal linking the gain is close to zero; for a catalogue with tens of thousands of URLs or a brand-new domain it is real.
What should never go into a sitemap?
Anything you do not want in search results: redirected URLs, 404s, pages with noindex, non-canonical versions, URLs with sorting and filter parameters, and technical sections. A sitemap is a statement that says these are my important pages, and Google does not resolve a conflict between that statement and your other signals in your favour — it simply stops trusting the file.
How do I check that robots.txt is not blocking too much?
Search Console has a robots.txt report showing which version the crawler read and when. Individual URLs are checked with the URL Inspection tool, which tells you whether crawling is allowed. Separately, review the Pages report — the Blocked by robots.txt category must not contain any page you need in search results.
Should filter and sorting pages be blocked in robots.txt?
Usually yes, but only if they should not rank. The important nuance: blocking in robots.txt does not remove URLs that are already indexed. If they are already in search results, the order is the opposite — first allow crawling and serve noindex or canonical, wait for a recrawl, and only then block them in robots.txt if crawl budget makes it worthwhile.
How often should sitemap.xml be updated?
It should update automatically when pages are published and removed — a hand-maintained file on a live site always drifts from reality sooner or later. Fill lastmod honestly: if it changes for every URL at once on each regeneration, Google stops taking it into account and you lose a useful signal.

Conclusion

Sitemap.xml and robots.txt are the cheapest files on a site to set up and the ones where a mistake costs the most: a single wrong Disallow line can pull an entire section out of search, and no amount of content compensates for that. The rule I have settled on over the years: robots.txt should be short and boring, and sitemap.xml should be an honest list of the pages you actually want in search results. If it turns out the junk URLs are generated by the CMS itself, that is no longer a two-text-file problem but a question of indexing rules — which is where I usually start a technical audit.

About the author

Vladislav Krivorutsko — founder of ADLAB
Vladislav Krivorutsko

Founder of ADLAB OÜ · SEO and Google Ads

Over 20 years in search traffic and monetization, and on the Estonian market since 2017. I work solo: I run the audit, build the strategy and deliver the project myself — no subcontractors, no templates. I only write about what I have tested on my own and client sites.

  • 20+ years in search traffic
  • 50+ end-to-end projects
  • Own sites in competitive niches
  • SEO for ru/et/en in one market
More about me

Read next