How to Create, Find and Check an XML Sitemap: Generators and Examples
An XML sitemap gives search engines a list of the pages you want them to find. It is simple in principle, but many sitemaps cause more confusion than help: they list redirected or deleted pages, include pages marked noindex, sit at an address nobody declared, or were made once by a generator and never updated. This guide shows what a valid XML sitemap looks like, with an example file you can copy, how to find the sitemap on any site, and how to create one with WordPress, Shopify, Next.js, an online generator or by hand. It then shows how to check and edit the file and confirm every URL in it before you submit it to Search Console.
What an XML sitemap is for
An XML sitemap is a file that lists the URLs on your site you want search engines to know about, optionally with the date each one last changed. It helps crawlers discover pages, especially new pages, pages with few internal links, and large sites where some sections are deep in the structure. It does not force anything into the index: Google still decides what to crawl and index, and a page in your sitemap can still be left out if it is thin, duplicated or blocked.
The format is defined by the sitemaps.org protocol, which Google, Bing and other engines all support. The limits that matter:
| Rule | Detail |
|---|---|
| Size per file | Up to 50,000 URLs and 50 MB uncompressed; split into several files and use a sitemap index beyond that |
| Encoding | UTF-8, with special characters escaped, for example & for an ampersand |
| URLs | Full absolute addresses, on the same host and protocol as the site |
lastmod | Used by Google when it is consistently accurate; set it when the page content really changes |
changefreq and priority | Ignored by Google; harmless but not worth maintaining |
A sitemap should contain only canonical URLs that return 200 and that you want indexed. Redirects, 404s, noindexed pages and parameter duplicates do not belong in it, and a sitemap full of them makes the whole file less trustworthy as a signal.
A valid XML sitemap example
This is a complete, valid sitemap for a small site. You can copy it as a starting point and change the addresses:
<?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/menu/cakes</loc>
<lastmod>2026-09-14</lastmod>
</url>
<url>
<loc>https://example.com/contact</loc>
</url>
</urlset>
Each page sits in its own <url> element with a <loc>. The lastmod value uses the W3C date format, either a date or a full date and time with a time zone such as 2026-10-01T09:30:00+01:00.
A sitemap index for larger sites
<?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>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
</sitemap>
</sitemapindex>
Submit the index and search engines read every child file listed in it. Splitting by type, such as pages, posts and products, also makes the Search Console report easier to read. See sitemap size limits if you are close to the caps.
How to find the XML sitemap on a site
There is no single required address, so check these in order:
- robots.txt. Open
https://example.com/robots.txtand look for aSitemap:line. This is the most reliable clue, because it is where sites declare their sitemap. - Common addresses. Try
/sitemap.xml,/sitemap_index.xml(Yoast and Rank Math),/wp-sitemap.xml(WordPress core) and/sitemap-index.xml. - Search Console. For your own site, the Sitemaps report lists every sitemap submitted for the property and when Google last read it.
- Your platform. Shopify publishes
/sitemap.xmlautomatically, and most CMS SEO plugins show the address on their settings screen.
From a terminal you can check the status and the type of file the server returns:
curl -sI https://example.com/sitemap.xml | grep -iE '^(HTTP|content-type)'
curl -s https://example.com/robots.txt | grep -i '^sitemap'
A healthy result is a 200 with a content type such as application/xml or text/xml. If you get an HTML page, the address is probably being caught by a 404 page or a redirect.
Ways to create an XML sitemap
| Method | Best for | Watch out for |
|---|---|---|
| CMS or plugin (WordPress, Shopify, Wix, Squarespace) | Most small business sites; updates itself | Noindexed or thin archive pages being included by default |
| Framework code (Next.js, Nuxt, Astro) | Custom builds; generated from your real routes | Forgetting dynamic pages such as products |
| Online generator | Small static sites with no build process | A one-off snapshot that goes stale; free tiers often cap the number of URLs |
| Desktop crawler export | Checking what is linkable, then exporting | Includes only what it can reach through links |
| By hand in a text editor | A handful of pages | Typing errors and unescaped ampersands |
WordPress
WordPress has produced a basic sitemap at /wp-sitemap.xml since version 5.5. Yoast and Rank Math replace it with their own index at /sitemap_index.xml and let you exclude post types and taxonomies. See sitemap_index.xml in WordPress.
Next.js
// app/sitemap.ts
import type { MetadataRoute } from 'next';
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const products = await getProducts();
return [
{ url: 'https://example.com/', lastModified: new Date('2026-10-01') },
...products.map((p) => ({ url: `https://example.com/products/${p.slug}`, lastModified: p.updatedAt })),
];
}
Online generators
A generator crawls your site from the home page and writes the file for you to download and upload to the root. It only finds pages reachable through links, and the file does not update itself, so regenerate it whenever you add or remove pages. For any site that changes, a CMS or build-time sitemap is the better long-term option.
How to check an XML sitemap before submitting
Check three things: the file is valid XML, every URL in it is a live canonical page, and the server delivers it correctly. Validate the syntax with xmllint, which is available on most Linux and macOS systems:
curl -s https://example.com/sitemap.xml -o sitemap.xml
xmllint --noout sitemap.xml && echo "well formed"
# list every URL and its status code
grep -o '<loc>[^<]*' sitemap.xml | sed 's/<loc>//' | while read u; do
printf '%s %s\n' "$(curl -s -o /dev/null -w '%{http_code}' "$u")" "$u"
done | sort | uniq -c -w3
Every line should start with 200. Anything showing 301, 404 or 5xx needs removing or fixing. Then open a sample of pages and confirm the canonical tag points at the same URL that is listed. The sitemap 404s guide and sitemap mismatches guide cover the usual problems.
A worked example
Example Bakery submits /sitemap_index.xml from its SEO plugin and Search Console shows Success, but only 40 of 120 listed URLs are indexed. Running the status loop shows 30 URLs returning 301, because the plugin lists old http addresses from an imported product feed, and 25 tag archive pages that carry noindex. The bakery fixes the feed so products use https URLs, excludes tag archives in the plugin's sitemap settings and resubmits. The listed count drops to 65, all returning 200 and self-canonical, which gives Google a clean list to work through.
The fix, step by step
Step 1
Check whether you already have one
Look for a Sitemap: line in your robots.txt, then try /sitemap.xml, /sitemap_index.xml and /wp-sitemap.xml. Check the Sitemaps report in Search Console for anything already submitted. Many platforms create a sitemap automatically, and running two in parallel, such as WordPress core and a plugin, only causes confusion. If one exists and is generated by your platform, skip to the checking steps rather than creating another.
Step 2
Choose how it will be generated
Use the built-in or plugin sitemap if you run WordPress, Shopify or another CMS, framework code such as app/sitemap.ts for a custom build, or an online generator or hand-written file for a small static site. Prefer a method that updates automatically when pages change. Write down which tool owns the sitemap, so nobody later adds a second generator that publishes a conflicting file.
Step 3
Decide which URLs belong in it
Include only pages you want in search results: canonical, indexable URLs that return 200. Exclude redirects, 404s, pages marked noindex, login and cart pages, internal search results and filtered or sorted duplicates. In a plugin, switch off post types and archives you do not want indexed. On a large site, split the list by type and plan a sitemap index that points at each file.
Step 4
Create the file with valid markup
Generate or write the file using the urlset element with the sitemaps.org namespace, one url element per page and a full https address in each loc. Add lastmod only where you know the real date of the last meaningful change. Escape any ampersand in a URL as the XML amp entity. Save as UTF-8 and place the file at the root, for example /sitemap.xml, unless your platform serves it for you.
Step 5
Validate the XML
Download the live file with curl and run xmllint --noout sitemap.xml. No output means it is well formed; an error message gives the line number of the problem. Also confirm with curl -sI that the address returns 200 with an XML content type rather than an HTML page. A file that opens in a browser can still fail validation, so do not skip this step.
Step 6
Check every listed URL
Extract each loc address and fetch its status code with a short curl loop, then count the results. Every URL should return 200. Remove or correct any that redirect or fail, and fix the generator setting that let them in so they do not come back. Spot-check that listed pages carry a canonical tag pointing to themselves and no noindex tag.
Step 7
Declare it in robots.txt
Add a line such as Sitemap: https://example.com/sitemap.xml to your robots.txt, using the full address. For a sitemap index, declare the index rather than each child file. Fetch robots.txt afterwards to confirm the line appears in the live file. This lets Bing and other search engines find the sitemap without needing it submitted to their own webmaster tools, and it keeps working if someone changes the Search Console setup.
Step 8
Submit it in Search Console
Open Sitemaps in Search Console for the correct property, enter the sitemap address and submit. The status should change to Success once Google has read it, and the report shows how many URLs it discovered. If it shows errors or Couldn't fetch, test the address again with curl. Over the following weeks, compare the listed pages with the Pages report to see how many are indexed.
Edge cases worth knowing
- Couldn't fetch in Search Console. This status can mean the file was blocked, returned an error, or simply has not been fetched yet. Test the address with curl first; the sitemap could not be read guide covers the rest.
- Image, video and news extensions. Google supports extra namespaces for images, videos and news articles inside a sitemap. Most small sites do not need them, because Google finds images in the page itself, but they can help media-heavy sites.
- hreflang in sitemaps. Language alternates can be declared in the sitemap with
xhtml:linkelements instead of in each page. See hreflang in sitemaps. - Compressed sitemaps. A gzipped file such as
sitemap.xml.gzis allowed; the 50 MB limit applies to the uncompressed size. - Cross-host URLs. A sitemap normally lists URLs on its own host only. Listing another domain's pages needs proof of ownership of both, through Search Console or robots.txt.
- Fake lastmod dates. Setting every
lastmodto today on each build teaches Google to ignore the field. See sitemap lastmod.
Keeping the sitemap accurate
Prefer a sitemap that is generated from your content, so it changes when pages are added or removed. Declare it in robots.txt as covered in creating a robots.txt file, keep it submitted in Search Console, and glance at the Sitemaps and Pages reports monthly. After a migration or redesign, rerun the status check, because old URLs often linger in the file.
1. How do I create an XML sitemap for my website?
Most sites should let their platform create it: WordPress core, Yoast or Rank Math, Shopify and most website builders generate a sitemap automatically. For a custom site, generate it from your routes with framework code, or use an online generator or a hand-written file for a small static site. Whichever you choose, list only indexable pages that return 200, validate the file, add a Sitemap line to robots.txt and submit it in Search Console.
2. How do I find the XML sitemap on a site?
Open the site's robots.txt file and look for a line starting with Sitemap, which gives the full address. If there is none, try common addresses such as sitemap.xml, sitemap_index.xml and wp-sitemap.xml at the root of the domain. For your own site, the Sitemaps report in Google Search Console lists every sitemap that has been submitted. Platforms such as Shopify always publish theirs at sitemap.xml on the main domain, so that is always worth trying first.
3. How do I check if my XML sitemap is valid?
Download it and run an XML validator such as xmllint, which reports any broken tags or encoding errors with a line number. Then check that the server returns it with a 200 status and an XML content type, and that each URL inside returns 200 rather than a redirect or a 404. Finally, submit it in Search Console and confirm the status shows Success with the number of discovered URLs you expect.
4. Can I use an online XML sitemap generator?
Yes, for a small site that rarely changes. An online generator crawls your pages from the home page and gives you a file to upload to your site's root folder. The drawbacks are that it only finds pages reachable through links, free versions often limit the number of URLs, and the file becomes out of date as soon as you add or remove pages. A sitemap your CMS or build process generates is easier to keep accurate.
5. Can I edit my sitemap.xml by hand?
You can edit a static sitemap in any plain text or code editor, as long as you keep the XML structure intact and escape special characters such as ampersands. Validate the file after every change. If your sitemap is generated by a CMS or plugin, do not edit the output directly, because the next update will overwrite it; change the plugin settings or the content instead, such as excluding a post type or setting a page to noindex.
6. Do priority and changefreq matter in a sitemap?
Not for Google, which has said it ignores both values. They are part of the sitemaps.org protocol and are harmless to include, but there is little point maintaining them. The optional field that can matter is lastmod, which Google uses when it is consistently accurate. Set it to the date the page content genuinely last changed, not the date the file was generated, or Google will learn to disregard it.
7. Does a sitemap get my pages indexed?
No, a sitemap helps Google discover and recrawl URLs, but it does not guarantee indexing. Google still assesses each page on quality, duplication and whether it is allowed to be crawled and indexed. A sitemap is most useful for new sites, large sites and pages with few internal links. If submitted pages are not indexed, look at the Pages report in Search Console for the reason given for each URL.
The robots and sitemap checker reads your sitemap from robots.txt, validates it and tests the listed URLs for redirects, errors and noindex tags so you submit a clean file.
Open Robots and Sitemap Fixes โ