XML sitemaps and robots.txt explained for business

Learn how XML sitemaps and robots.txt files work together to guide search engine crawlers, protect private URLs, and ensure clean Google indexation.

By Shariq Riaz5 min readMore SEO guides

An XML sitemap and a robots.txt file are two core technical files that control how search engines discover and crawl your website. Your robots.txt file sets crawl rules by telling search bots which directories they may or may not visit, while your XML sitemap provides a clean roadmap of all live pages you want indexed in search results. Configuring both files properly prevents crawl budget waste, shields administrative pages, and ensures new content appears in Google promptly.

Understanding how these two files interact helps you avoid accidental indexation disasters that can make an entire website vanish from search results.

What is a robots.txt file?

A robots.txt file is a plain text file stored in the root directory of your web server at yourdomain.com/robots.txt. When an automated web crawler, such as Googlebot or Bingbot, visits your domain, it requests your robots.txt file before attempting to crawl any other page.

The file communicates using the Robots Exclusion Protocol, which consists of three standard directives:

  • User-agent: Identifies the specific search crawler the rule applies to. Using an asterisk (*) applies the rule to all compliant bots.
  • Disallow: Specifies directory paths or URL patterns that bots are forbidden from requesting.
  • Allow: Explicitly permits access to a specific subfolder within an otherwise disallowed directory.
  • Sitemap: Lists the complete, absolute URL of your XML sitemap.

A standard robots.txt example

Here is a typical robots.txt file for a WordPress or custom business site:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /checkout/
Disallow: /cart/
Disallow: /search/

Sitemap: https://www.yourdomain.com/sitemap_index.xml

In this example, search bots are instructed to avoid administrative dashboards, checkout paths, and dynamic internal search results, while public marketing pages remain accessible.

The critical difference between disallowing and noindexing

One of the most frequent technical SEO mistakes is assuming that adding a URL to robots.txt prevents it from appearing in Google search results.

A disallow rule tells Googlebot: "Do not crawl or download the contents of this URL."

However, if external websites or internal navigation links point to that disallowed URL, Google knows the address exists. Because Googlebot cannot read the page to see a noindex tag, it will often index the bare URL anyway. In search results, users will see the URL with a message stating: "No information is available for this page."

To reliably keep a page out of Google search results:

  1. Allow the page in robots.txt so Googlebot can crawl it.
  2. Add a <meta name="robots" content="noindex, follow"> tag to the HTML head of the page, or return an X-Robots-Tag: noindex HTTP response header.
  3. Once Google crawls the page and reads the noindex directive, it removes the URL from its search index.

For managing duplicate or parameter URLs, canonicalization is often the better solution. Read our guide on canonical tags and duplicate content to explore when to use canonical tags instead of blocking bots.

What is an XML sitemap?

An XML sitemap is a structured XML document that lists the specific URLs on your website that you want search engines to crawl and index.

Unlike human-facing HTML sitemaps, which serve as visual directories in website footers, XML sitemaps are written exclusively for search engine machines:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.yourdomain.com/services/commercial-roofing</loc>
    <lastmod>2026-10-15T12:00:00+00:00</lastmod>
  </url>
</urlset>

In modern XML sitemaps:

  • <loc> specifies the complete canonical URL.
  • <lastmod> specifies the date and time the page was last updated, informing crawlers whether the content has changed since their last visit.
  • Historical tags like <changefreq> and <priority> are largely ignored by Google today, as algorithms determine crawling cadence through automated monitoring.

XML sitemap best practices for business websites

To maintain an effective XML sitemap, follow these technical standards:

1. Include only canonical 200-status URLs

Your sitemap should represent your cleanest indexable inventory. Never include:

  • URLs that return 301 or 302 redirects.
  • Broken pages that return 404 or 410 error codes.
  • Pages containing a noindex meta tag.
  • Non-canonical URLs created by tracking parameters or sorting filters.

2. Use sitemap index files for larger catalogs

A single sitemap file is limited to 50,000 URLs and a maximum uncompressed file size of 50 megabytes. You can also compress sitemaps using gzip format (sitemap.xml.gz) to save bandwidth when crawlers fetch large catalogs.

If you operate an ecommerce store with thousands of products or publish hundreds of articles, split your URLs across multiple thematic sitemaps organized under a parent sitemap index:

  • /post-sitemap.xml
  • /page-sitemap.xml
  • /product-sitemap.xml

Your master sitemap at /sitemap_index.xml links to each sub-sitemap, simplifying management and troubleshooting. Modern content management systems generate these dynamic sitemap index files automatically whenever you publish, edit, or remove pages.

3. Keep lastmod dates accurate

Only update the <lastmod> timestamp when you make meaningful content changes. Artificially updating lastmod dates on static pages without actual content edits causes search engines to mistrust your timestamps over time. Automated CMS setups handle this cleanly by recording database update timestamps when posts are saved.

How robots.txt and XML sitemaps work together

These two files complement each other to create a clean crawl environment:

FilePrimary roleLocationTarget audience
robots.txtRestricts crawler access to sensitive or duplicate pathsyourdomain.com/robots.txtAll web spiders and scrapers
XML sitemapRecommends URLs for discovery and indexationyourdomain.com/sitemap.xmlSearch engine indexing algorithms

Always include your XML sitemap URL at the bottom of your robots.txt file. This ensures any compliant search crawler that visits your domain discovers your complete page inventory immediately.

Next, submit your sitemap directly to Google Search Console and Bing Webmaster Tools. Submitting your sitemap enables Search Console to report any indexation errors or unindexed URLs. For step-by-step submission instructions, see our Google Search Console guide.

Common mistakes that damage search visibility

Watch out for these frequent configuration blunders:

Accidental site-wide disallow rules

During website development, designers frequently add this rule to staging environments to prevent premature indexing:

User-agent: *
Disallow: /

If your development team launches your new website without removing this line, Googlebot will stop crawling your site immediately, causing organic rankings and traffic to drop within days. Always verify your live robots.txt file immediately after launching any redesign or migration. Cross-reference our SEO website migration guide to safeguard traffic during platform changes.

Submitting sitemaps with mixed protocols

Ensure all URLs inside your sitemap use your final, secure domain protocol (HTTPS) and canonical subdomain format. If your live site resolves to https://www.yourdomain.com, your sitemap must not list http:// or non-www URLs.

Inconsistencies between robots.txt and sitemaps

Never include a URL in your XML sitemap that is disallowed in your robots.txt file. This sends conflicting instructions to search algorithms, triggering warning notifications in Google Search Console.

To run a complete audit across your crawl directives, review our technical SEO checklist.

Professional technical crawl management

Maintaining clean crawl architecture and resolving indexation warnings prevents valuable pages from dropping out of search results.

At Techcelerant, our team audits robots.txt directives, configures automated XML sitemaps, and manages crawl budget optimization. Explore our comprehensive SEO services or review our transparent tiers on our pricing page. You can also contact our team to resolve any crawling or indexing challenges.

Frequently asked questions

What is the difference between an XML sitemap and robots.txt?

A robots.txt file tells search engine crawlers which parts of your website they are allowed or forbidden to access. An XML sitemap acts as a curated list of all public URLs you want search engines to crawl and index. While robots.txt manages crawl permissions, the XML sitemap highlights content priority and discovery.

Does a robots.txt file stop Google from indexing a page?

No, not reliably. A disallow directive in robots.txt only stops search bots from crawling the page content, but Google can still index the URL if other websites or internal links point to it. To completely prevent a page from showing up in search results, use a meta noindex tag or password protection instead.

Where should the robots.txt and sitemap files be located?

Your robots.txt file must always live in the root directory of your domain at yourdomain.com/robots.txt. Your XML sitemap typically lives at yourdomain.com/sitemap.xml or sitemap_index.xml. You should also include a direct line pointing to your sitemap URL inside the robots.txt file.

How many URLs can an XML sitemap contain?

A single standard XML sitemap file can contain up to 50,000 URLs and cannot exceed 50 megabytes in uncompressed file size. If your website has more pages or larger file weights, you can split your links across multiple sitemaps and organize them using a sitemap index file. This approach is common for large ecommerce stores and publication archives.

Fix your robots.txt and sitemap setup

We review your crawl directives and XML sitemaps to resolve indexing issues and quote a fixed price.

We reply within one business day. No spam, no mailing list.

Keep reading

All articles