How to Create an XML Sitemap for a Website
An XML sitemap tells search engines which pages you want found. Here's what to include, how to structure it for large sites, and how to keep it accurate.
By SEO Tool OrbitUpdated November 9, 20265 min read

Search engines find most pages by following links. A sitemap gives them a second route: a machine-readable list of the URLs you consider important, with an optional note of when each last changed. It won't fix a weak site structure, but it helps new pages get discovered sooner and makes your intent clear.
In short: list only canonical, indexable URLs that return 200. Keep each sitemap file under 50,000 URLs and 50 MB uncompressed, and use a sitemap index to group several files. Generate sitemaps automatically from your CMS or a crawler, reference them in robots.txt, submit them in Search Console and Bing Webmaster Tools, and check the reports for errors.
What an XML sitemap does — and doesn't do
- It does help search engines discover URLs, especially new pages, deep pages and pages with few links.
- It does tell search engines which version of each URL you consider canonical.
- It doesn't force indexing. Search engines still decide whether a page is worth indexing.
- It doesn't replace internal links. A page found only through a sitemap is usually a page with a linking problem.
A minimal sitemap
<?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-10-01</lastmod>
</url>
<url>
<loc>https://example.com/guides/xml-sitemaps</loc>
<lastmod>2026-09-18</lastmod>
</url>
</urlset>
Each <loc> must be an absolute URL on the same host as the sitemap. The file must be UTF-8 encoded, and special characters such as & in URLs must be escaped.
Which URLs should be included
| Include | Exclude |
|---|---|
| Canonical versions of indexable pages | Duplicates, parameter variants and non-canonical URLs |
| Pages that return 200 | Redirects, 404s and server errors |
| Pages you want in search results | noindex pages, login and account pages, internal search results |
| Important media (in image or video sitemaps, if useful) | URLs blocked in robots.txt |
Consistency matters: if a URL is in your sitemap, it should also be the canonical URL on the page and the one your internal links use. Mixed signals make search engines guess. The canonical tags guide explains how the signals fit together.
About lastmod, changefreq and priority
lastmod is useful when it's accurate: set it to the date the page's main content last changed, not the date the sitemap was generated. Google has said it uses lastmod when it's consistently reliable and ignores changefreq and priority, so there's no benefit in tuning those two.
Sitemap indexes for large websites
One sitemap file can hold up to 50,000 URLs and be up to 50 MB uncompressed. Larger sites split URLs across several files and list the files in 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/sitemaps/articles-1.xml</loc>
<lastmod>2026-10-01</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/products-1.xml</loc>
</sitemap>
</sitemapindex>
Splitting by content type (articles, products, categories) has a practical benefit: Search Console then reports indexing per file, so you can see which section has problems.
Generating sitemaps for CMS-based websites
Hand-written sitemaps go stale. Most platforms can generate them: WordPress has a built-in sitemap and SEO plugins that extend it; Shopify, Wix and Squarespace create one automatically; frameworks such as Next.js can generate sitemaps from the same data that builds your pages. Whatever the method, check the output — generators sometimes include noindexed pages, drafts or parameter URLs.
For a site without built-in support, the Sitemap Generator crawls the site and builds a ready-to-upload sitemap containing only real, working, indexable pages.
Other sitemap types
- Image sitemaps add image entries to page URLs, useful when images are central to the content — see the image SEO guide.
- Video sitemaps describe video content, such as title, thumbnail and duration, for pages built around videos.
- News sitemaps are for publishers in Google News and list recent articles only.
- hreflang annotations in sitemaps link the language versions of a page, an alternative to adding them in each page's head. Our international SEO guide has a worked example.
Common XML sitemap errors
- URLs that redirect, return 404 or are marked noindex.
- HTTP URLs on an HTTPS site, or
wwwURLs on a non-wwwsite. - Unescaped ampersands, which make the XML invalid.
lastmodset to the same date on every URL, or updated every day regardless of changes.- Sitemaps that are blocked by robots.txt or require a login.
- A stale sitemap that misses new sections entirely.
Submitting and monitoring a sitemap
- Add a line to robots.txt:
Sitemap: https://example.com/sitemap.xml. The Robots.txt Generator can include it for you. Our robots guide covers the other directives. - Submit the sitemap (or sitemap index) in Google Search Console and in Bing Webmaster Tools.
- Check the Sitemaps report after a few days: it shows whether the file was read and how many URLs were discovered.
- Compare submitted URLs with the Page indexing report to find pages that were submitted but not indexed, and investigate why — our guide to pages Google isn't indexing explains each reason.
Google retired its sitemap "ping" URL in 2023, so pinging no longer works there; an accurate lastmod and the robots.txt reference do the job instead.
A sitemap checklist
- Every URL returns 200, is indexable and is canonical.
- All URLs use the same protocol and host as the site.
- The file is valid XML, UTF-8, within the size limits.
lastmodreflects real content changes.- The sitemap is referenced in robots.txt and submitted to search engines.
- It's generated automatically, so new and removed pages are reflected without manual work.
How to validate a sitemap
- Open the file in a browser: invalid XML shows an error immediately.
- Spot-check a sample of URLs with the HTTP Status Code Checker — every one should return 200.
- Use the Sitemaps report in Search Console for parsing errors and warnings.
- Include sitemaps in your regular technical SEO audit.
Sites with many important images can also add image entries — the image SEO guide explains when that's worthwhile.
Frequently asked questions
Does a small website need a sitemap?
Not strictly — if every page is well linked, search engines will find them. A sitemap is still cheap insurance and helps new pages get found faster.
Should every page be in the sitemap?
Only the canonical, indexable pages you want to appear in search. Leaving out the rest makes the sitemap a clean signal.
How quickly will pages be indexed after I submit a sitemap?
There's no fixed time. Discovery may be quick; indexing depends on whether search engines judge the pages worth indexing.
Next step
Open your sitemap, check ten URLs at random, and remove anything that redirects, errors or is noindexed. If you don't have one yet, generate it with the Sitemap Generator and submit it in Search Console.
- #Technical SEO
- #Crawling & Indexing
Related reading

Technical SEO
How to Perform a Technical SEO Audit Step by Step
A technical audit answers one question: can search engines reach, understand and index your important pages? Here is the order to check things in, and what to fix first.
6 min read

Technical SEO
Robots.txt vs Meta Robots vs X-Robots-Tag
Robots.txt controls crawling; meta robots and X-Robots-Tag control indexing. Mixing them up is one of the most common ways sites accidentally disappear from search.
5 min read

Technical SEO
How to Use Canonical Tags to Prevent Duplicate URL Problems
The same page often lives at several addresses. Canonical tags tell search engines which one to index — when they agree with your other signals.
5 min read

Website Optimization
How to Optimize Images for SEO, Accessibility, and Speed
Image SEO is mostly careful HTML. Here's how to mark up images so they load fast, describe themselves to screen readers, and can be found in image search.
5 min read