Technical SEO

What Is an XML Sitemap & How You Can Create One for SEO (with Examples)

A complete guide to XML sitemaps: what they do, what belongs in one, how to create & submit them, with working examples & the mistakes that quietly waste crawl budget.

A Big Shout Out6 min read
Start reading

An XML sitemap is a file that lists the pages on your site you want search engines to know about. It is written for machines rather than people, & it sits at a fixed address so a crawler can find it without hunting.

It is one of the simplest technical SEO assets to get right, & one of the most commonly misunderstood. Plenty of sites publish a sitemap listing every URL they have ever generated, which does more harm than publishing none at all.

What an XML sitemap actually does

A sitemap is a suggestion, not an instruction. It tells a search engine "these URLs exist & I consider them worth looking at". It does not force indexing, it does not guarantee a ranking, & it will not rescue a page that has no value.

What it genuinely helps with is discovery. If a page is buried deep in your architecture, has few internal links pointing at it, or is brand new, a sitemap is often how a crawler finds it first. On a large site it also gives you a clean signal about which URLs you consider canonical.

The second, underrated benefit is diagnostic. Once a sitemap is submitted, Google Search Console will tell you how many of the URLs in it are indexed. If you submit 480 URLs & 120 are indexed, that gap is one of the most useful numbers in technical SEO. It tells you something is wrong before your traffic does.

What a basic sitemap looks like

The format is plain XML. Here is a minimal, valid example:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-07-20</lastmod>
  </url>
  <url>
    <loc>https://example.com/services/technical-seo</loc>
    <lastmod>2026-07-14</lastmod>
  </url>
</urlset>

Only two things matter here. The urlset namespace must be exactly as shown, & every loc must be a full absolute URL including the protocol.

About the optional tags

lastmod is worth including, but only if it is honest. It should reflect when the content meaningfully changed, not when your CMS last touched the row. Google has said publicly that it ignores lastmod values it does not trust, & a site where every URL claims to have been modified today is exactly the pattern that earns that distrust.

changefreq & priority are effectively ignored by Google. You can include them, but do not spend any time tuning them. A priority value of 1.0 on every page communicates nothing.

What belongs in a sitemap, & what does not

The rule is simple. A sitemap should contain the canonical, indexable URLs you want in search results. Nothing else.

Include: canonical URLs that return a 200 status, are not blocked by robots.txt, carry no noindex tag, & point their canonical tag at themselves.

Exclude:

  • Redirects. A URL that 301s should not be in the sitemap. Update the entry to the destination instead.
  • 404 & 410 pages. Obviously, but they accumulate quietly on sites that generate sitemaps from a stale database table.
  • Any page carrying noindex. Telling a crawler to index a page & not index it in the same breath is a contradiction it resolves by trusting the tag & distrusting your sitemap.
  • Non canonical variants. If /shoes?colour=blue canonicalises to /shoes, only /shoes belongs in the file.
  • Paginated series beyond the first page, in most cases.
  • Pages blocked in robots.txt. Again a direct contradiction.
  • Login, cart, checkout, account & internal search results pages.

The test we apply is blunt. If you would not be pleased to see a URL appear in search results, it should not be in the sitemap.

Sitemap index files, for larger sites

A single sitemap may contain up to 50,000 URLs & must be no larger than 50MB uncompressed. Past that, you split the file & reference the parts from a sitemap index.

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-pages.xml</loc>
    <lastmod>2026-07-20</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-blog.xml</loc>
    <lastmod>2026-07-24</lastmod>
  </sitemap>
</sitemapindex>

Split by content type rather than arbitrarily. Separate sitemaps for pages, blog posts, products & categories mean Search Console reports indexing rates per section, which turns a vague "some pages are not indexed" into "62% of product pages are missing". That is a diagnosis you can act on.

Image & video sitemaps

You can attach image data to a normal sitemap entry using the image namespace:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
  <url>
    <loc>https://example.com/work/case-study</loc>
    <image:image>
      <image:loc>https://example.com/img/case-study-hero.jpg</image:loc>
    </image:image>
  </url>
</urlset>

This is worth doing when images drive discovery, for example in retail, property, travel & hospitality. For a typical B2B service site it is rarely the bottleneck.

How to create one

If you use a CMS, the platform almost certainly generates one already. WordPress produces /wp-sitemap.xml by default, & Yoast or Rank Math will produce their own. Shopify creates /sitemap.xml automatically. Check what already exists before building anything.

If you are on a custom build, generate the file dynamically from the same query that decides what is publicly visible. That way the sitemap cannot drift out of sync with the site. A static file that someone has to remember to regenerate will be wrong within a month.

If the site is small & static, writing the file by hand is entirely reasonable. Twenty URLs do not need a build pipeline.

Whatever generates it, the file must be served with a content type of application/xml or text/xml. Serving XML as text/html is a surprisingly common misconfiguration.

How to submit it

  1. Publish the file at a stable URL, conventionally https://yourdomain.com/sitemap.xml.
  2. Reference it from robots.txt with a line reading Sitemap: https://yourdomain.com/sitemap.xml. This is how crawlers other than Google will find it.
  3. Submit it in Google Search Console under Indexing then Sitemaps.
  4. Submit it in Bing Webmaster Tools, which also feeds several other engines.
  5. Come back in a fortnight & read the indexed versus submitted numbers.

Common mistakes worth checking for today

Mixed protocols or hostnames. Listing http:// URLs when the site runs on HTTPS, or mixing www & non www. Every URL must match your canonical hostname exactly.

A sitemap that never updates. If you published in 2023 & the file still lists the pages you had then, it is actively misleading.

Listing every URL the database can produce. Filtered, sorted & parameterised URLs balloon the file & dilute the signal.

Treating the sitemap as an indexing fix. If pages are not being indexed, the sitemap is where you notice the problem, not where you solve it. The cause is usually thin content, duplication, poor internal linking or a crawl issue.

The short version

Keep it clean, keep it canonical, keep it current, & read the coverage numbers it gives you. A sitemap is not a ranking tactic. It is a diagnostic instrument, & most sites are not reading the dial.

Next step

Have a goal in mind? Let’s talk.

A quick conversation is all it takes to see what’s possible & where we can start.

Typical first reply: under 24 hoursNo obligation