Skip to content

Sitemap or robots.txt: What Each One Does

Up to date as of 1 December 2026

A sitemap says "these are the pages I'd like you to find". A robots.txt file says "please stay out of these places". One invites. The other asks for restraint.

The sitemap, in one line

A sitemap tells search engines which pages and files you think are important on your site.1 It's a list of pages you hope people will find in search.

The robots.txt file, in one line

It tells crawlers which URLs they can access on your site. Google says its main use is to stop your server being swamped by requests.2

Picture a receptionist with a visitor list. The list says which rooms a guest may enter. It doesn't describe the building, and it doesn't promise every guest will obey.

Side by side

Sitemap robots.txt
Main job Lists pages you want found Tells crawlers where they may go
Tone An invitation A request to stay out
Where it sits Site root recommended; see below Must be at the site root

You can host a sitemap anywhere on your site, but unless you submit it through Search Console, it affects only URLs in its own directory and below. That is why Google recommends the site root.3 The robots.txt file has to sit at the root of the site host.4

Two files, two jobsCrawler visits your siterobots.txt: where it may goSitemap: pages you want foundCrawler decides what to visit
Both sit on your site. Crawlers read both.

A common mix-up

Leaving a page out of a sitemap doesn't hide it. Google says omitting or removing a URL from your sitemap doesn't prevent Google from crawling or indexing it, if it finds the page through links from other sites.1

The reverse is also true. Putting a rule in robots.txt doesn't keep a page out of search results. That has its own page, on blocked pages that still appear.

Short version: neither file is a privacy tool. Google says respectable crawlers obey a robots.txt file, but other crawlers might not.2

Here's a quick test. Ask what you want to happen to the page. If the answer is "I want it found", it belongs in a sitemap. If the answer is "I'd rather crawlers skipped it", think about robots.txt. If the answer is "nobody should see it", you need a password. Each file answers a different question.

How the two files meet

They can point to each other. You can add a line to your robots.txt file that gives the sitemap's address. The sitemaps.org protocol says you can specify the location of the Sitemap using a robots.txt file.5

Google adds that sitemaps are a good way to indicate which content Google should crawl, as opposed to which content it can or cannot crawl.4

The exact line is on How to Give Your Sitemap to Search Engines.

Which one do you need?

Start with the question you're asking.

Cited material

  1. What Is a Sitemap, Google Search Central
  2. Robots.txt Introduction and Guide, Google Search Central
  3. Build and Submit a Sitemap, Google Search Central
  4. Create and Submit a robots.txt File, Google Search Central
  5. sitemaps.org Protocol, sitemaps.org