Guide · Jul 7, 2026

XML Sitemap vs robots.txt: What Each One Actually Controls

Both files sit at the root of your domain, both get generated early in a project's life, and both get mentioned in the same SEO checklists — so it's easy to end up treating them as two halves of one thing. They're not. A sitemap and a robots.txt file control almost opposite ends of how a search engine interacts with your site, and mixing up what each one does is a quick way to accidentally hide pages you meant to have indexed, or leave crawlers wasting time on ones you didn't.

robots.txt: what crawlers are allowed to fetch

robots.txt is a set of instructions about which URLs a crawler is permitted to request in the first place. It's checked before anything else — before the page loads, before its content is read. A Disallow rule tells well-behaved crawlers "don't request this path at all," which is useful for keeping bots out of admin panels, internal search result pages, staging directories, or anything that generates infinite low-value URLs (calendar widgets are a classic offender).

What it doesn't do: control whether a page appears in search results. A disallowed page can still show up in Google's index — usually with no description, just the bare URL — if other sites link to it, because Google knows the URL exists even though it was never allowed to crawl the content. robots.txt is also not access control. It's a request that well-behaved bots honor voluntarily; nothing stops a browser, a script, or a less scrupulous crawler from ignoring it, so it should never be the only thing standing between the public and something sensitive.

sitemap.xml: what pages exist and roughly how fresh they are

A sitemap does the opposite job: instead of restricting access, it's a direct list handed to search engines saying "here are the URLs on this site, and here's roughly when each one last changed." It doesn't grant or restrict permission to crawl anything — a URL can be blocked by robots.txt and listed in a sitemap at the same time, which is a contradiction worth avoiding (more on that below) but isn't a technical error either file will complain about on its own.

Listing a URL in your sitemap doesn't guarantee it gets indexed, and it has no direct effect on ranking. What it does is remove "the crawler never found this page" as a possible reason a page is missing from search — which matters most for pages that aren't well linked internally, like an old blog post several pages deep in pagination, or a tool page that only the footer links to.

Where the two are supposed to meet

The one place these files are meant to reference each other: robots.txt should contain a line pointing to your sitemap's location —

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

This isn't required for either file to function on its own, but it's a small, free hint that lets any crawler find your sitemap immediately after reading robots.txt, rather than needing to be told the location separately through each search engine's webmaster tools.

The contradiction that trips people up

Disallowing a path in robots.txt while also listing pages under that path in your sitemap sends a mixed signal — you're simultaneously telling crawlers "don't fetch this" and "here's this, please index it." Google's usual behavior is to respect the disallow and mostly ignore the sitemap entry for that URL, but it's an easy inconsistency to introduce by accident: someone adds a Disallow: /drafts/ rule for a new section, and the sitemap generator — run separately, on a different schedule — keeps quietly including those same URLs because nothing links the two processes together.

The practical fix is just to treat sitemap generation and robots.txt rules as connected decisions rather than separate chores owned by different tools or people. If a path is blocked, it shouldn't be in the sitemap; if it's meant to be discovered and indexed, it shouldn't be blocked.

FAQ

If I want a page removed from Google entirely, is Disallow in robots.txt enough?

No — this is the single most common misunderstanding of the two files. Disallow only blocks crawling, not indexing; a blocked page that's linked from elsewhere can still appear in results. To actually keep a page out of the index, use a noindex meta tag or header on the page itself (which requires the page to be crawlable so Google can see the tag), or remove the page and return a real 404/410 status.

Do I need a sitemap if my site only has a dozen pages?

Not urgently — a small, well-linked site gets crawled fine without one. It becomes genuinely useful once you have enough pages, or a deep enough link structure, that some pages are more than a couple of clicks from the homepage. It costs nothing to add either way.

Can I just block crawlers from my whole staging site with robots.txt?

You can, and it's common practice, but remember it's not real access control — pair it with a password, IP allowlist, or a noindex header if the staging environment shouldn't be publicly reachable at all, since robots.txt alone won't stop a direct visit or an unscrupulous crawler.

Generate what you need

FreeToolDev's sitemap generator turns a pasted list of URLs into a valid sitemap.xml in one pass. If you'd rather not compile that URL list by hand, the Site Crawler & Audit tool crawls your site automatically and can generate the sitemap, an RSS feed, and an llms.txt file from the same crawl.