XML Sitemaps and Robots.txt: A Practical Guide for Site Owners
Two Files That Control How Google Sees Your Website

XML Sitemaps and Robots.txt: A Practical Guide for Site Owners
MOST WEBSITE OWNERS NEVER LOOK AT THESE TWO FILES — UNTIL SOMETHING GOES WRONG AND HALF THEIR SITE DISAPPEARS FROM SEARCH RESULTS. OUR EXPERTS WROTE THIS GUIDE TO HELP BUSINESS OWNERS AND DEVELOPERS UNDERSTAND EXACTLY WHAT THESE FILES DO, WHAT COMMANDS BELONG IN EACH ONE, AND HOW TO CONFIGURE THEM CORRECTLY SO GOOGLE CRAWLS AND INDEXES YOUR SITE THE WAY YOU ACTUALLY WANT IT TO.
What’s Inside This Guide
1. What These Files Actually Do — and Why Both Matter
2. Sitemap Configuration: Structure, Directives, and Real Examples
3. Crawl Control File: Directives, Commands, and Common Configurations
4. Critical Errors That Break Indexing — and How to Fix Them
5. FAQ
What These Files Actually Do — and Why Both Matter
There is a common misconception that these two technical files are redundant — that they both tell Google what to crawl, so you only need one. This misunderstanding leads to configurations that contradict each other and produce indexing results nobody intended. The two files actually serve entirely different functions, and understanding the distinction is the foundation of using them correctly.
The sitemap is a communication file. It tells search engine crawlers which pages exist on the website, when they were last modified, and how they relate to each other in the site’s structure. Think of it as a map you hand to a delivery driver — here are all the addresses I want you to visit. It doesn’t force anything. Google is not required to index every URL listed in a sitemap. What it does is make those URLs visible and easy to discover, which accelerates crawling and indexing of new or updated content significantly compared to relying on Google to find pages by following links.
The crawl control file is a permission file. It tells crawlers which parts of the website they are and are not allowed to access. Think of it as a set of signs on the doors of a building — some doors say “employees only,” others say “open to visitors.” It governs access at the crawl level. A URL that appears in the sitemap but is blocked in the crawl control file creates a direct conflict that confuses crawlers and often results in inconsistent indexing behavior. The two files need to be consistent with each other and with the noindex directives used in page-level meta tags — a three-layer system where all three layers need to agree about which pages should appear in search results.
📌 The Three-Layer Indexing System:
Layer 1 — Crawl control file: Controls which URLs crawlers can access at all
Layer 2 — Sitemap: Communicates which URLs exist and should be considered for indexing
Layer 3 — Meta robots tag on page: Controls whether a specific page should be indexed once crawled
All three layers must be consistent. Contradictions between layers produce unpredictable indexing behavior that is difficult to diagnose without checking all three simultaneously.
The practical stakes of getting these files wrong are significant. A single line in the crawl control file that accidentally blocks a critical section of the site can cause that entire section to disappear from search results within days of a re-crawl. A sitemap that includes non-canonical URLs, pagination pages, or URLs with session parameters wastes Google’s crawl budget and dilutes the signals that matter for ranking. A misconfigured crawl file deployed after a site migration has caused complete search visibility loss for businesses that didn’t catch the error quickly. The guide on how to build a website that ranks covers how these technical files fit into the broader architecture of a well-built site — and why they need to be planned before development, not added as an afterthought after launch.
Sitemap Configuration: Structure, Directives, and Real Examples
A well-formed sitemap is an XML file following a defined protocol that search engines understand. The file lives at the root of the domain — typically at yourdomain.com/sitemap.xml — and is submitted to Google Search Console so Google’s systems know where to find it. The basic structure follows a consistent pattern regardless of how complex the site is, and understanding that pattern makes it possible to evaluate whether any generated sitemap is doing its job correctly.
The minimum required structure for a valid sitemap looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.yourdomain.com/</loc>
<lastmod>2024-03-15</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://www.yourdomain.com/services/</loc>
<lastmod>2024-02-28</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Each directive within the URL entry serves a specific purpose. The <loc> tag is the only mandatory element — it contains the exact canonical URL of the page. Every URL must be absolute (including the https:// prefix), must use the same protocol and subdomain as the canonical version of the page, and must be accessible to crawlers without requiring authentication. A URL listed as http:// when the site canonicalizes to https:// creates a mismatch that can cause the sitemap entry to be ignored.
The <lastmod> tag tells crawlers when the page was last meaningfully updated. “Meaningfully” is the key word — updating this date on every page automatically whenever the sitemap regenerates, even when the page content hasn’t changed, trains Google to treat the signal as unreliable and eventually ignore it. Use <lastmod> accurately: update it only when the page content has genuinely changed in a way that warrants re-crawling. A format of YYYY-MM-DD is the accepted standard.
The <changefreq> tag is a hint to crawlers about how often the page content typically changes. The accepted values are: always, hourly, daily, weekly, monthly, yearly, never. This tag is treated as a suggestion rather than an instruction — Google does not guarantee it will crawl at the indicated frequency. For most business service pages that change rarely, “monthly” is appropriate. For actively-updated blog sections, “weekly” or “daily” is more accurate. For static pages like privacy policies or terms of service, “yearly” or “never” is correct.
The <priority> tag indicates the relative importance of a URL compared to other URLs on the same site. Values range from 0.0 to 1.0, with 0.5 as the default. The homepage typically receives 1.0, main service and category pages 0.8, secondary pages 0.6, and supporting content 0.4 or lower. This tag is purely relative — it communicates the hierarchy within your own site, not absolute importance compared to other sites. Google uses it as a signal for prioritizing its crawling queue when resources are limited, not as a ranking factor.
📄 Sitemap Index File — When Your Site Is Large:
A single sitemap file can contain a maximum of 50,000 URLs and must not exceed 50MB uncompressed. Sites exceeding either limit need a sitemap index file — a parent file that references multiple child sitemaps. The structure looks like this:
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.yourdomain.com/sitemap-pages.xml</loc>
</sitemap>
<sitemap>
<loc>https://www.yourdomain.com/sitemap-blog.xml</loc>
</sitemap>
</sitemapindex>
What should be excluded from the sitemap is as important as what should be included. Every URL in the file represents a page you’re actively asking Google to consider indexing. Including pages that shouldn’t be indexed — pagination pages, filtered category URLs, internal search result pages, thin content pages, pages with noindex meta tags — wastes crawl budget and sends conflicting signals. The rule is straightforward: if a page has a noindex meta tag, it should not appear in the sitemap. If a page has a canonical tag pointing to a different URL, the non-canonical version should not appear in the sitemap. Only canonical, indexable URLs belong in the file.
| Sitemap Check | What to Verify | Why It Matters |
|---|---|---|
| Protocol consistency | All URLs use https:// matching site canonical | HTTP/HTTPS mismatch causes sitemap entries to be ignored |
| No noindex pages included | Cross-check sitemap URLs against meta robots tags | Contradiction between sitemap inclusion and noindex tag confuses crawlers |
| No non-canonical URLs | Only the canonical version of each URL is listed | Non-canonical URLs in sitemap dilute crawl budget |
| Submitted to Search Console | Sitemap URL submitted and showing no errors | Unsubmitted sitemaps rely on Google discovering them — slower and less reliable |
| Lastmod dates accurate | Dates reflect actual content changes, not auto-generated timestamps | Inaccurate lastmod trains Google to ignore the signal entirely |
Crawl Control File: Directives, Commands, and Common Configurations
The robots.txt file lives at the root of every domain — at yourdomain.com/robots.txt — and it’s the first thing most well-behaved crawlers check before accessing any other page on the site. Its syntax is simple but its consequences are significant. A single incorrect line can block an entire site from being crawled. Understanding the core directives and how they interact is non-negotiable for anyone responsible for a website’s technical health.
The basic structure of the file uses two primary directives: User-agent and Disallow. User-agent specifies which crawler or crawlers the following rules apply to. Disallow specifies which URLs or URL patterns the specified crawler should not access. A basic configuration for a standard business website looks like this:
User-agent: * Disallow: /wp-admin/ Disallow: /wp-login.php Disallow: /cart/ Disallow: /checkout/ Disallow: /my-account/ Disallow: /thank-you/ Disallow: /search/ Allow: /wp-admin/admin-ajax.php Sitemap: https://www.yourdomain.com/sitemap.xml
The User-agent: * line applies the rules to all crawlers. For rules specific to Google’s crawler only, you would use User-agent: Googlebot. For rules specific to Bing, User-agent: Bingbot. Multiple user-agent blocks are permitted in the same file, and more specific rules for named crawlers take precedence over the wildcard rules when both apply to the same crawler.
The Disallow directive accepts either a specific path (/wp-admin/) or a pattern. A disallow of / with no path following it blocks the entire site from being crawled — one of the most catastrophic single-line errors possible. A disallow of /search blocks all URLs starting with /search. The matching is prefix-based: /services/ blocks /services/ and /services/seo/ and /services/ppc/ but not /our-services/ because the prefix doesn’t match. This prefix behavior is a common source of unintended blocks when the path isn’t terminated with a slash.
The Allow directive explicitly permits access to a URL or pattern that would otherwise be blocked by a more general Disallow rule. The example above uses it for /wp-admin/admin-ajax.php — a common WordPress pattern where the entire wp-admin directory is blocked, but the admin-ajax.php file needs to remain accessible because themes and plugins use it to load dynamic content on public pages. Without the explicit Allow, the general Disallow on /wp-admin/ would prevent this file from being loaded, which can cause broken functionality on publicly-accessible pages.
🔎 Pattern Matching in Disallow Directives — Real Examples:
# Block all URLs containing ?s= (WordPress search queries) Disallow: /*?s= # Block all PDF files sitewide Disallow: /*.pdf$ # Block a specific parameter pattern (session IDs) Disallow: /*?sessionid= # Block staging subdirectory Disallow: /staging/ # Block all printer-friendly page variants Disallow: /*/print/
The Sitemap directive at the end of the crawl control file is technically optional but practically important. It tells any crawler reading the file where to find the sitemap, which accelerates discovery. The value should be the full absolute URL including protocol. If the site uses a sitemap index file, reference the index file URL here rather than individual sitemap files — the index file then points to all individual sitemaps.
Crawl-delay is a directive supported by some crawlers (including Bingbot and various other bots) that instructs the crawler to wait a specified number of seconds between requests. It is not supported by Googlebot, which manages its own crawl rate based on server response times and signals set in Search Console. For sites with server performance concerns, adjusting crawl rate through Search Console’s crawl settings is the correct mechanism for Google — not a Crawl-delay directive in the crawl control file.
⚠️ The Blocking-but-Not-Noindexing Problem:
One of the most counterintuitive behaviors in crawl management: blocking a URL in the crawl control file does not prevent Google from indexing it. Google can still index a URL it cannot crawl if that URL receives links from other pages — it will just index it without being able to read its content. The result is often a “Discovered — currently not indexed” status in Search Console, or worse, a thin page appearing in results because Google indexed the URL without being able to read what’s on it. To prevent a page from appearing in results, a noindex meta tag on the page itself is required — and the page must be crawlable for that tag to be read.
For e-commerce sites, the crawl management requirements are more complex because the URL surface area is significantly larger. Filter and sort parameters generate hundreds or thousands of URL variants that are functionally duplicate content. Faceted navigation creates similar problems. The following configuration addresses common e-commerce crawl waste:
User-agent: * Disallow: /cart/ Disallow: /checkout/ Disallow: /my-account/ Disallow: /order-received/ Disallow: /wishlist/ Disallow: /*?color= Disallow: /*?size= Disallow: /*?sort= Disallow: /*?page= Disallow: /internal-search/ Allow: / Sitemap: https://www.yourdomain.com/sitemap.xml
- ► Always test the crawl control file using Google Search Console’s robots.txt tester before deploying changes to a live site
- ► After any CMS migration, template update, or URL restructuring, verify the file hasn’t changed — CMS updates frequently overwrite it
- ► Keep the file in plain text with Unix line endings — Windows-style line endings can cause parsing errors in some crawler implementations
- ► Never include the staging or development version of a site in the production crawl control file — use a separate file with Disallow: / on staging environments
- ► Monitor the file in Search Console’s Index Coverage report for any crawl errors introduced after changes
| Crawl File Feature | Google Search Console | Screaming Frog |
|---|---|---|
| Robots.txt tester | Built-in — tests any URL against current file | Crawl respects file and flags blocked URLs |
| Sitemap validation | Full validation with error reporting per URL | Can crawl sitemap and audit each URL |
| Blocked URL identification | Coverage report shows blocked pages | Blocked URLs highlighted in crawl results |
| Historical file versions | Shows Google’s cached version of the file | Not available — current file only |
| Cost | Free | Free tier available; paid from £149/year |
| Best use case | Primary monitoring and submission tool | Deep technical audit of crawl behavior |
| Noindex conflict detection | Coverage report flags noindex pages in sitemap | Can identify noindex pages included in sitemap |
| Crawl budget analysis | Crawl stats report shows crawled pages per day | Full crawl map with response codes and timing |
| Alert on file change | Not available natively | Not available natively |
| Multi-domain support | Separate property per domain required | Multiple crawls can run for different domains |
Critical Errors That Break Indexing — and How to Fix Them
The most damaging errors in these files are the ones that look correct until you examine their consequences. They don’t produce obvious error messages — they produce ranking drops and indexing gaps that take days or weeks to diagnose because the symptom appears far removed from the cause.
The most catastrophic single error is a Disallow: / line under User-agent: * with nothing following it to override it. This single line blocks all crawlers from accessing the entire site. It appears in production surprisingly often — it’s the default configuration many CMS platforms use for staging environments, and it regularly survives site migrations when the staging configuration is deployed to production without being reviewed. The fix is immediate: remove or comment out the line, verify the file, and submit it to Search Console. Rankings typically recover within two to four weeks of the block being removed, depending on how long the site was blocked.
# THIS WILL BLOCK YOUR ENTIRE SITE — DO NOT USE IN PRODUCTION User-agent: * Disallow: / # CORRECT VERSION FOR A LIVE SITE — ALLOWS FULL ACCESS User-agent: * Disallow: # OR SPECIFY ONLY WHAT SHOULD BE BLOCKED User-agent: * Disallow: /wp-admin/ Disallow: /private/
The noindex-in-sitemap conflict is the second most common critical error. It occurs when a page has a meta robots tag with noindex but the URL is still included in the sitemap. This creates a direct contradiction that Google resolves by ignoring the sitemap entry — but the inconsistency wastes crawl budget and creates noise in Search Console’s coverage reports. The fix is to regenerate the sitemap to exclude noindex URLs, either by configuring the CMS’s sitemap generator to exclude pages marked noindex, or by manually auditing the sitemap against the site’s noindex inventory.
Non-canonical URLs appearing in the sitemap is a subtler but significant error. When a site has both www and non-www versions, or both HTTP and HTTPS versions, accessible — and both versions are included in the sitemap — Google receives conflicting signals about which version is canonical. The sitemap should include only the canonical version of every URL, matching exactly the protocol and subdomain specified in the canonical tags throughout the site. A sitemap audit using Screaming Frog or the coverage data in Search Console typically surfaces this type of inconsistency quickly. Understanding how these technical foundations connect to the broader outcome of generating business from a website is covered in the guide on how to generate leads from your website — because technical correctness is only the foundation, not the complete picture.
📈 Post-Launch Crawl Health Checklist:
▶ Verify robots.txt is accessible at yourdomain.com/robots.txt and returns a 200 status code
▶ Test critical URLs against the file using Search Console’s robots.txt tester
▶ Confirm sitemap is accessible, returns valid XML, and shows no errors in Search Console
▶ Cross-check: no URL in the sitemap has a noindex meta tag
▶ Confirm Sitemap: directive in robots.txt points to the correct sitemap URL
▶ Check Search Console coverage report for “Blocked by robots.txt” and “Excluded by noindex” counts
Understanding how these crawl management decisions affect the timeline for search results is important context for anyone implementing these changes on an existing site. Fixing a crawl block that’s been in place for months doesn’t produce immediate ranking restoration — it restarts the crawling process, and rankings recover gradually as Google re-crawls and re-evaluates the previously blocked content. The guide on how long it takes to see results from search optimization work provides realistic expectations for post-fix recovery timelines. For the technical foundation that makes all of this work correctly together, the guide on what is link building shows how authority signals interact with the crawl infrastructure that determines whether those signals are properly attributed to the right pages. And for businesses that want to ensure their technical investment produces measurable outcomes, the framework for guaranteed search visibility services covers how accountable campaigns approach technical health as part of a complete optimization system.
🚫 Five Directives You Should Never Use Without Understanding Them:
1. Disallow: / — Blocks entire site. Only use on staging environments, never on production.
2. Noindex on category pages — Can remove entire content sections from results. Always audit scope first.
3. Crawl-delay: 10 — Affects all non-Google crawlers. On shared hosting it can slow legitimate monitoring tools significantly.
4. Disallow: /*.html — Blocks all HTML files. Catastrophic on sites with .html extensions.
5. User-agent: Googlebot / Disallow: / — Blocks only Google specifically. Produces complete Google invisibility while other search engines still crawl normally.
Frequently Asked Questions — Direct Answers
👉 My sitemap shows 200 URLs submitted but only 140 indexed. What happened to the other 60?
This is normal and doesn’t necessarily indicate a problem. Google does not guarantee indexing of every URL in a sitemap — it uses the sitemap as a discovery and prioritization signal, not as an indexing instruction. URLs may be excluded from indexing for several reasons: thin or duplicate content, low perceived quality relative to similar pages already indexed, crawl budget constraints on very large sites, or the page being too new for Google to have fully evaluated it. Check the Coverage report in Search Console to see how the unindexed URLs are classified — “Discovered, currently not indexed,” “Crawled, currently not indexed,” and “Excluded” categories each indicate different causes and different appropriate responses.
🔍 If I block a URL in the crawl control file, will Google stop showing it in search results?
Not necessarily — and this is the most important counterintuitive fact about crawl management. Blocking a URL prevents Google from reading its content, but it doesn’t prevent Google from indexing the URL itself if external links or internal links point to it. Google can know a URL exists without being able to access it, and may show it in results as a URL-only result with no description. To prevent a page from appearing in search results, the page must be crawlable (so the meta tag can be read) AND contain a noindex meta robots tag. Blocking AND noindexing simultaneously is contradictory and counterproductive — choose one approach. For pages you want out of results, use noindex with full crawl access. For pages you want to protect from crawling for other reasons (admin areas, private content), use the crawl block, and accept that the URL might still appear as an empty result if heavily linked.
⚠️ My developer says they’ll add the sitemap to the CMS automatically. Should I just trust that?
Trust but verify — always. CMS-generated sitemaps are frequently misconfigured in ways that aren’t immediately obvious. Common problems with auto-generated sitemaps include including noindex pages, including tag and category archive pages with thin content, including paginated pages that should be excluded, using incorrect protocols (HTTP instead of HTTPS), and failing to update lastmod dates accurately. After a developer configures sitemap generation, manually review the output by loading the sitemap URL and checking a sample of entries. Then submit to Search Console and monitor the coverage report for any errors it surfaces. Auto-generation is convenient but it doesn’t eliminate the need for a human review of the output.
The specific configuration options for sitemap generation vary significantly by CMS. WordPress with Yoast SEO or Rank Math provides granular control over which post types and taxonomies are included. Shopify generates sitemaps automatically with limited configuration options. Custom-built sites require the sitemap to be generated and updated through custom code or a dedicated tool. In all cases, the output needs to be verified against the inclusion criteria described in this guide.
💰 Does having a bigger sitemap help my site rank better?
No — sitemap size has no direct relationship to ranking performance. A sitemap with 10,000 URLs of mixed quality will perform worse than a sitemap with 300 URLs of consistently high-quality, indexable pages. Including low-quality, thin, or duplicate pages in the sitemap doesn’t improve their ranking prospects — it dilutes crawl budget that could be spent on your highest-value pages and sends signals about overall site quality that can be counterproductive. The goal is a sitemap that accurately represents the canonical, indexable, high-value pages on the site — not a sitemap that includes every URL that technically exists.
📌 Can having errors in the crawl control file cause a manual penalty from Google?
Errors in the file itself don’t trigger manual penalties — manual penalties are applied for guideline violations, not technical configuration mistakes. What crawl errors do cause is accidental indexing exclusion (if pages are unintentionally blocked) or crawl waste (if the file fails to block low-value URL patterns). Neither of these produces a manual penalty, but both can produce significant ranking drops that look alarming. The distinction matters because the recovery process is different: a manual penalty requires a reconsideration request after fixing the underlying issue, while a technical crawl error recovery just requires fixing the file and waiting for Google to re-process the affected pages — typically two to six weeks for full recovery.
🔹 How often should I audit these files?
At minimum: after every significant website change. This includes CMS updates, theme or template changes, URL restructuring, addition of new content sections, migration between hosting environments, and any change to the site’s domain or subdomain structure. CMS updates in particular have a documented history of overwriting customized crawl control files with default configurations. Beyond event-triggered audits, a quarterly review of both files against the current site structure — cross-checked against Search Console’s coverage report — catches drift between the technical configuration and the site’s actual content and indexing requirements. For high-traffic sites or sites undergoing active optimization campaigns, monthly reviews are worth the modest time investment.