XML sitemaps and robots.txt that actually help
What each file is for, how they work together, and the settings that quietly cause crawling and indexing problems.
These two files are small and easy to get wrong. One tells crawlers what they may request, the other tells them which pages you care about. This article is part of the complete technical SEO guide.
What each file does
| robots.txt | XML sitemap | |
|---|---|---|
| Purpose | Rules for what crawlers may request | A list of URLs you want known |
| Controls | Crawling | Discovery (a hint, not an order) |
| Lives at | The root of each host | Anywhere, usually the root |
| Read first by | Every well-behaved crawler | Search engines you submit it to |
Neither file guarantees indexing. Indexing depends on quality and on consistent signals.
robots.txt: the rules
The file follows the Robots Exclusion Protocol. A minimal useful version:
User-agent: *
Disallow: /cart/
Disallow: /search
Sitemap: https://example.com/sitemap.xml
Things that go wrong:
- Disallow: / on the live site. It is usually left over from staging. Check it after every launch.
- Blocking CSS and JavaScript. Search engines need them to render the page.
- Blocking pages that carry noindex. The crawler cannot read a tag on a page it may not fetch.
- Using it to hide pages. A blocked URL can still appear in results. For privacy, use authentication.
- One file assumed for all hosts. A subdomain and the http and https versions each have their own.
robots.txt also decides which AI crawlers may fetch your pages. Treat that as a business decision and set it deliberately. You can try rules in my robots.txt generator and tester. The glossary entry on robots.txt explains how the file works.
The sitemap: the list
A good sitemap is boring and accurate.
- Only canonical, indexable URLs that return 200. The XML sitemap entry explains what the file is for.
- Generated from the same source as the pages, so it cannot drift out of date.
- A real lastmod that changes only when the page really changes. A date that updates on every deploy teaches search engines to ignore it.
- Split by type on large sites (products, categories, articles), grouped in a sitemap index, so Search Console can report each group.
- Within limits: 50,000 URLs or 50 MB uncompressed per file.
- Consistent with the rest. If a sitemap lists URLs that are canonicalized elsewhere, or hreflang that does not match, you are sending contradictions.
Details worth knowing from Google’s documentation
robots.txt (create and submit):
- It sits at the root of the host it governs. A subdomain, or a non-standard port, can have its own file.
- It must be UTF-8 plain text.
- Directives are
user-agent,disallow,allowandsitemap. Paths start with/, rules are case-sensitive and*works as a wildcard in every rule exceptsitemap. - A crawler matches one group of rules, the most specific one, so a rule written for
*does not also apply to a crawler that has its own group.*does not match AdsBot, which must be named. - The
sitemapline takes a fully qualified URL and can appear more than once. - To test, open the file in a private window to confirm it is public, and use the robots.txt report in Search Console.
Sitemaps (build and submit):
- Google reads XML, RSS or Atom feeds and plain text lists. XML is the most versatile and can carry image, video and news extensions.
- One file holds up to 50 MB uncompressed or 50,000 URLs, and must be UTF-8. Use a sitemap index for more.
- URLs must be fully qualified, and should be the canonical versions.
- Google uses
lastmodonly if it is consistently and verifiably accurate, and it should reflect significant changes, not minor edits such as a copyright year. It ignorespriorityandchangefreq. - Without a Search Console submission, a sitemap covers only its own directory and below, so keep it at the root.
- You can submit through Search Console, its API or a
Sitemap:line in robots.txt. Submission is a hint, not a promise to crawl.
Figures reported from a Google talk in October 2026, not official documentation, put sitemap processing and a robots.txt update at about 24 hours each. The article on Google’s reported crawl and index timings lists these figures with their caveats.
How to check them together
- Open
/robots.txtand confirm it returns 200, has no blanket block, and names the sitemap. - Open the sitemap and sample URLs for status code, noindex and canonical.
- In Search Console, submit the sitemap and compare the submitted count with the indexed count.
- Filter the Page indexing report to the sitemap: pages that are submitted but not indexed are the ones to investigate.
A small checklist
- robots.txt returns 200 and contains no leftover staging rules.
- The sitemap is listed in robots.txt and submitted in Search Console.
- Only canonical 200 pages are in the sitemap.
- lastmod is truthful.
- AI crawler access is a decision, not an accident.
I can review this under technical SEO audit service, get in touch and send over the details.
FAQ
Should the sitemap include every page?
No. Include the pages you want indexed: canonical, indexable and returning 200. Redirected, noindex, duplicate and error pages only send mixed signals.
Can robots.txt block a page and still keep it in Google?
The page can still be listed without its content if other pages link to it. To keep a page out of search results, use noindex on a crawlable page, or put it behind a login.
Do I need to list the sitemap in robots.txt?
It is a simple, standard way to make it discoverable. Also submit it in Search Console so you get a report for it.
Sources
- What is a sitemap · Google Search Central
- Build and submit a sitemap · Google Search Central
- Sitemaps XML protocol · sitemaps.org
- Robots.txt introduction and guide · Google Search Central
- Create and submit a robots.txt file · Google Search Central
- RFC 9309: Robots Exclusion Protocol · IETF (RFC Editor)
- Google crawling, indexing and serving timing data (report of a Search Central Live talk, Oct 2026) · Search Engine Roundtable
Keep reading
- Technical SEO audit or monthly SEO: which do you need first?How to choose between a one-time technical audit and ongoing monthly SEO, and why an audit usually comes first.
- Core Web Vitals: what to fix firstHow to read the three metrics, where the thresholds are, and an order of work that fixes templates instead of chasing single pages.
- Log file analysis in practiceWhat server logs show that crawlers and reports do not, how to read them step by step, and what to fix once you can see what bots really request.
Related glossary terms
Want this applied to your site?
Tell me about your site and I’ll suggest the next step.
Work with me Services