An XML sitemap tells search engines which pages you want found. A robots.txt file tells them where they may not go. Used together they help crawlers spend their time on pages that matter. Used carelessly, they can hide your whole site.
robots.txt
A plain text file at the root of the domain (https://example.com/robots.txt):
User-agent: *
Disallow: /api/
Disallow: /search
Disallow: /preview/
Sitemap: https://example.com/sitemap.xml
- Disallow stops crawling of paths that have no value in search: internal search results, APIs, previews, carts.
- It does not remove a page from search results. A disallowed page can still appear if other sites link to it. To keep a page out of results, let it be crawled and use a
noindexrobots meta tag instead. - Never block CSS or JavaScript files that pages need to render.
The XML sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/blog/core-web-vitals-explained</loc>
<lastmod>2026-10-14</lastmod>
</url>
</urlset>
Include:
- every page you want in search results, with its canonical URL;
- an accurate lastmod date when the content really changed.
Leave out:
- pages with
noindex, redirects and 404s; - duplicate URLs (tracking parameters, sorting options);
- pages blocked in robots.txt.
A sitemap can hold up to 50,000 URLs; larger sites split it into several files listed in a sitemap index.
Submit and monitor
- Reference the sitemap in robots.txt.
- Submit it in Google Search Console and Bing Webmaster Tools.
- Check the Pages report regularly: it shows which submitted URLs were indexed and why others were not.
Common mistakes
| Mistake | Effect |
|---|---|
Disallow: / left over from a staging site | The whole site stops being crawled |
| Sitemap lists URLs that redirect | Crawlers waste time; signals get diluted |
| Every page has today's date as lastmod | Search engines learn to ignore your dates |
| Using robots.txt to hide a page from results | The page can still be indexed from links |
| Sitemap not updated when pages are published | New pages are found late |
Keep it automatic
The sitemap should be generated from your content, updated when something is published, and never edited by hand. Add a check to your launch checklist that robots.txt on production does not block the site, and consider an uptime check with an assertion on the sitemap URL so you notice if it ever breaks.
Does robots.txt remove pages from Google?
No. It only stops crawling. To keep a page out of results, allow crawling and add a noindex robots meta tag.
Do I need a sitemap for a small site?
Not strictly, if every page is linked, but it helps new pages get found faster and costs nothing when generated automatically.
How many URLs can a sitemap contain?
Up to 50,000 URLs or 50 MB uncompressed. Larger sites use a sitemap index that lists several sitemaps.
Try VitalRix free
Uptime monitoring, APM, logs, real user monitoring and status pages in one place. No credit card needed.