Technical SEO 5 min read

XML sitemaps and robots.txt: what they do and how to set them up

What XML sitemaps and robots.txt do, how they differ, how WordPress and Shopify generate them, what to include and the common mistakes that block pages from search.

Usman Muhammad UsmanUpdated October 13, 2026
XML sitemaps and robots.txt: what they do and how to set them up

XML sitemaps and robots.txt are two small files that shape how search engines crawl your site. They are often confused, and a mistake in either can keep pages out of search or waste crawl effort on junk URLs. This guide explains what each does, how WordPress and Shopify handle them and how I set them up.

What an XML sitemap is

An XML sitemap is a list of the URLs you want search engines to know about, often with the date each was last modified. It helps search engines discover pages, especially new ones and pages with few internal links. It does not guarantee indexing.

Large sites usually have a sitemap index that links to several smaller sitemaps, for example one for posts, one for pages and one for products. Each sitemap can list up to 50,000 URLs.

What robots.txt is

Robots.txt is a text file at the root of your domain that tells crawlers which parts of the site they may or may not crawl. It uses simple rules such as User-agent and Disallow. Well-behaved crawlers follow it; malicious bots ignore it.

Robots.txt controls crawling, not indexing. A URL blocked by robots.txt can still appear in search results if other pages link to it, usually without a description. To keep a page out of search, allow crawling and use a noindex tag.

Sitemap vs robots.txt
XML sitemaprobots.txt
PurposeList pages to discoverControl crawling
Location/sitemap_index.xml or /sitemap.xml/robots.txt
Controls indexing?NoNo, use noindex
Should containCanonical, indexable URLsFew, careful rules
Check afterPlugin changesEvery launch

How WordPress generates them

WordPress creates a basic sitemap at /wp-sitemap.xml and a virtual robots.txt automatically. SEO plugins such as Rank Math and Yoast replace the core sitemap with their own, usually at /sitemap_index.xml, with more control over what is included.

WordPress’s virtual robots.txt is served unless a physical robots.txt file exists in the site root. SEO plugins let you edit robots.txt from the dashboard. Check which version is live by visiting yourdomain.com/robots.txt.

How Shopify handles them

Shopify generates a sitemap automatically at /sitemap.xml, including products, collections, pages and blog posts. Its default robots.txt blocks cart, checkout, search and many filter URLs. You can customise robots.txt with a robots.txt.liquid template.

Edit Shopify’s robots.txt carefully; the defaults are sensible for most stores. See Shopify SEO basics.

What to include in the sitemap

Include only canonical, indexable pages that you want in search: important pages, posts, products, useful categories. Exclude noindexed pages, redirects, 404s, duplicate URLs, thin tag archives, attachment pages and private content.

A clean sitemap helps search engines trust it. A sitemap full of redirects and noindexed pages sends mixed signals. Set SEO plugin options to exclude post types and taxonomies you do not want indexed.

Submitting the sitemap

Submit your sitemap in Google Search Console under Sitemaps and in Bing Webmaster Tools. Add a Sitemap line to robots.txt pointing to the sitemap URL, which helps other search engines find it.

Search Console shows whether the sitemap was read successfully and how many URLs were discovered. Compare the number of submitted URLs with indexed pages in the Pages report to spot problems.

Writing robots.txt rules

A typical WordPress robots.txt allows everything except the admin area, while allowing admin-ajax.php, which some front-end features use, and lists the sitemap. Avoid blocking CSS and JavaScript files, which Google needs to render pages properly.

Use Disallow rules for areas with no search value, such as internal search results or endless filter combinations on large stores. Test rules in Search Console’s robots.txt report before relying on them.

Common robots.txt mistakes

The most damaging mistake is a Disallow: / rule left from development, which blocks the whole site. Others include blocking the wp-content folder, which hides images and styles, blocking pages that have noindex tags, so crawlers never see the noindex, and blocking important sections by accident with broad rules.

Check robots.txt after every launch, migration and SEO plugin change. My technical SEO audit includes this check.

Common sitemap mistakes

Common sitemap mistakes include listing non-canonical URLs, including staging or development URLs, outdated sitemaps that are not updated automatically and multiple sitemaps from different plugins competing with each other.

Make sure only one sitemap system is active. If you switch SEO plugins, update the sitemap URL in Search Console and robots.txt.

Image and video sitemaps

SEO plugins can include images in sitemaps, helping Google find images for image search. Video sitemaps or VideoObject schema help video content appear in video results. For most business sites, image entries in the main sitemap are enough.

News sites can use news sitemaps for Google News. These specialised sitemaps are only useful for specific content types.

Crawl budget for large sites

For small sites, crawl budget is rarely an issue; Google can crawl everything. For large stores and publishers with tens of thousands of URLs, wasted crawling on filters, parameters and duplicates can delay indexing of important pages.

Use robots.txt to block crawl traps, keep sitemaps clean and fix redirect chains. See why is my page not indexed.

Getting help

Sitemap and robots.txt configuration is part of my technical SEO service. Small mistakes here can have large effects, so I check them on every launch and migration.

For a full checklist, see my technical SEO audit and SEO migration checklist.

Key takeaways

  • Sitemaps help discovery; robots.txt controls crawling, not indexing.
  • Include only canonical, indexable URLs in your sitemap.
  • Never block CSS, JavaScript or pages with noindex tags in robots.txt.
  • Check robots.txt after every launch and migration.

Frequently asked questions

Where is my robots.txt?

At yourdomain.com/robots.txt. WordPress serves a virtual one unless a physical file exists.

Where is my WordPress sitemap?

Usually /wp-sitemap.xml by default, or /sitemap_index.xml with Rank Math or Yoast.

Does a sitemap guarantee indexing?

No. It helps discovery; Google decides what to index based on quality and other signals.

Should I block wp-admin in robots.txt?

Many sites disallow /wp-admin/ while allowing admin-ajax.php. It has little SEO impact either way.

How often is the sitemap updated?

SEO plugins and Shopify update it automatically when content changes.

Can I have more than one sitemap?

Yes, through a sitemap index. Avoid competing sitemaps from different plugins.

Free website audit

Get a free audit of your website

Tell me your URL and I'll send a short, prioritized list of the speed, SEO and security fixes that will make the biggest difference.

  • No obligation, no sales call
  • 5.0 rating on Google and Upwork
  • Reply within one business day
Written by Muhammad UsmanWeb Development Team Lead with 5+ years building WordPress, WooCommerce, Shopify and Wix websites. Experience · Certificates About me

More on Technical SEO

All Technical SEO articles

Have a project in mind?

Tell me what you're building and I'll reply with next steps and an estimate.