عWork with me

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.

Ahmed Ali · 4 min read
1robots.txtwhat may be crawled2Sitemapwhich URLs matter3Crawlpages are fetched4Indexpages are stored
robots.txt sets the rules, the sitemap lists the pages, and links lead the crawler to them.

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, allow and sitemap. Paths start with /, rules are case-sensitive and * works as a wildcard in every rule except sitemap.
  • 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 sitemap line 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 lastmod only if it is consistently and verifiably accurate, and it should reflect significant changes, not minor edits such as a copyright year. It ignores priority and changefreq.
  • 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

  1. Open /robots.txt and confirm it returns 200, has no blanket block, and names the sitemap.
  2. Open the sitemap and sample URLs for status code, noindex and canonical.
  3. In Search Console, submit the sitemap and compare the submitted count with the indexed count.
  4. 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

Keep reading

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
Book a free audit call

Work with me

Tell me about your site and goals. I usually reply within 24 hours.

Your message comes straight to me. I usually reply within 24 hours.

Esc

↑↓ move · Enter open · Esc close