How to Create an XML Sitemap: A Step-by-Step Guide for SEO

Google allows 50,000 URLs or 50MB per sitemap and ignores priority tags. Here is how to build, check and submit an XML sitemap step by step.

An open brass pocket compass on a chain lies on top of a printed world map.
Photo: Denise Jans via Unsplash

Key Takeaways

An XML sitemap is a UTF-8 file that lists the canonical URLs you want search engines to find, with up to 50,000 URLs or 50MB per file. Most CMS platforms build one automatically, so the real work is checking it, cleaning it and submitting it to Google.

  • One sitemap holds 50,000 URLs or 50MB uncompressed.
  • List only canonical, absolute URLs you want indexed.
  • Google ignores the priority and changefreq values.
  • Lastmod counts only when it is consistently accurate.
  • Submit through Search Console or a robots.txt line.

What an XML sitemap does

A list of URLs for crawlers

Google's sitemap overview describes a sitemap as a file that tells search engines which pages and files matter on your site. It helps discovery, but it does not guarantee that every listed URL will be crawled and indexed.

Leaving a URL out of the sitemap also does not hide it. To keep a page out of Google Search, Google says to block indexing with noindex.

How it differs from robots.txt

A sitemap invites crawlers to URLs, while robots.txt tells them where not to go. The two files work together, and our guide to robots.txt covers the second one.

The formats Google accepts

Google supports XML, RSS, mRSS, Atom 1.0 and plain text sitemaps, and says it has no preference. XML is the most versatile, because extensions can add images, video, news and localized versions of pages.

A text sitemap is simply one URL per line in a file with a .txt extension. An HTML sitemap page can help visitors, but it is not a format you can submit in Search Console.

If your CMS already publishes an RSS or Atom feed, you can submit the feed URL as a sitemap. Google notes that feeds usually list only recent URLs, so they work best alongside a full XML file.

Step 1: Decide whether you need one

Sites that benefit most

Google lists three cases where a sitemap helps:

  • Large sites: some new pages may not be linked from anywhere.
  • New sites: few external links point crawlers to the pages.
  • Media-heavy sites: video, images or Google News content.

For media-heavy sites, Google says it can take extra information from sitemaps into account for Search. Image, video and news extensions carry that information in the XML format.

Sites that may not need one

Google defines a small site as about 500 pages or fewer that you want in search results. If those pages are comprehensively linked from the home page, a sitemap may add little.

Even so, Google says most sites benefit from having one. A sitemap costs almost nothing to maintain once the CMS generates it.

Step 2: Choose the URLs to include

Canonical URLs only

The Google build guide says to include the URLs you want to see in search results. Where the same content sits at several addresses, list only the canonical one.

If you have separate mobile and desktop URLs, Google recommends pointing to one version. Both can be listed only if you annotate them.

What to leave out

Keep out redirects, error pages, noindex pages and parameter duplicates. Every URL in the file should return a working page you would be happy to rank.

A quick audit helps here. Crawl the sitemap URLs once a quarter and remove anything that no longer returns a live, indexable page.

Order does not matter

Google says the order of URLs in a sitemap makes no difference. Group them in whatever way makes the file easy for your team to maintain.

Step 3: Create the sitemap file

Let your CMS do it

Google notes that CMS platforms such as WordPress, Wix and Blogger have likely already made a sitemap available. Search your platform's help docs for how it generates sitemaps before building anything.

Write it by hand for small sites

For fewer than a few dozen URLs, Google says you can write the file in a text editor. The sitemaps protocol sets out the structure:

  • urlset: the required wrapper that declares the sitemap namespace.
  • url: the required parent tag for each entry.
  • loc: the required page address, under 2,048 characters.
  • lastmod: the optional last modified date in W3C Datetime format.

Start the file with an XML declaration that sets UTF-8 encoding. Tag values must be entity escaped, so an ampersand in a URL becomes &.

Generate it for larger sites

Beyond a few dozen URLs, Google recommends generating the sitemap from your website software or database. Hand-built large sitemaps are tedious and hard to keep current.

Step 4: Follow the rules Google checks

Size and encoding

Every format is limited to 50,000 URLs or 50MB uncompressed per file. You can gzip the file to save bandwidth, but the 50MB limit still applies to the uncompressed size.

The file must be UTF-8 encoded, and every URL must be fully qualified and absolute. Write https://www.example.com/page/ rather than /page/.

Location

Unless you submit through Search Console, a sitemap only affects URLs below its own directory. Google therefore recommends posting it at the site root.

Tags Google ignores

Google ignores the priority and changefreq values. It uses lastmod only when the dates are consistently and verifiably accurate.

Lastmod should mark the last significant update, such as a change to main content, structured data or links. Updating a copyright year does not count.

The sitemaps protocol allows a plain YYYY-MM-DD date. It also says the date must reflect when the page changed, not when the sitemap was generated.

Step 5: Submit the sitemap to Google

Search Console

The Sitemaps report in Google Search Console lets you submit the file and see when Googlebot fetched it. It also shows processing errors.

Google stresses that submitting a sitemap is a hint. It does not guarantee that Google will download the file or crawl every URL.

The robots.txt line

You can add a line such as Sitemap: https://example.com/sitemap.xml anywhere in robots.txt. Google finds it the next time it crawls that file, and there is no limit on how many sitemap lines you add.

The Search Console API

Developers can submit sitemaps programmatically through the Search Console API. That suits sites that publish many new sections on a schedule.

Sites that use Atom or RSS feeds can also use WebSub to broadcast changes to search engines, including Google. That speeds up discovery for frequently updated feeds.

Step 6: Scale with a sitemap index

When to split

Google's large sitemaps guide says to split files that pass the size limits and list them in a sitemap index. You then submit just the index file.

Sitemap indexes cannot be nested, and Search Console accepts up to 500 index files per site. Each listed sitemap must sit on the same site, in the same directory as the index or deeper.

Track sections separately

Separate sitemaps for posts, products and categories make Search Console reports easier to read. GrowthCentr arithmetic: a store with 120,000 product URLs needs at least three product sitemaps under one index.

Running several sites

Google allows one sitemap to list URLs for several verified sites, even on different domains. You can also keep each site's sitemap in a single shared location to simplify submission.

Keep checking after launch

Review the Sitemaps report after major site changes and fix errors quickly. Crawl health is only part of the picture, so keep an eye on Core Web Vitals as well.

Conclusion

Creating an XML sitemap means listing your canonical, absolute URLs in a UTF-8 file within Google's size limits, usually with your CMS doing the writing. Submit it in Search Console, add it to robots.txt and treat lastmod as a promise you keep accurate.

Frequently Asked Questions

How many URLs can an XML sitemap hold?

A single sitemap can hold up to 50,000 URLs or 50MB uncompressed, and larger sites must split it into several files.

Where should I put my sitemap?

Google recommends the site root, because a sitemap otherwise only affects URLs below its own directory unless submitted in Search Console.

Does Google use the priority tag?

No, Google ignores both the priority and changefreq values in XML sitemaps.

Do small sites need a sitemap?

A well-linked site of about 500 pages or fewer may not need one, though Google says most sites benefit from having it.

Can I use a text file as a sitemap?

Yes, Google accepts a .txt file that lists one URL per line and contains nothing else.

Does submitting a sitemap guarantee indexing?

No, Google treats a submitted sitemap as a hint and may not crawl or index every listed URL.

Sources: Google Search Central sitemap overview, build guide and large sitemaps guide; sitemaps.org protocol. Figures checked 2 December 2026. This article is for information only and is not financial, legal or purchasing advice.