How to Create an XML Sitemap (and Submit It)
Updated 11 September 2026 · 7 min read
An XML sitemap is a file that lists the URLs on your site you want search engines to know about. It doesn't force anything into search results, and it doesn't replace good internal linking. What it does is give crawlers a clean, complete list of your important pages, along with a hint about when each one last changed.
This guide covers the format as defined by the sitemaps.org protocol, the limits you need to stay within, how Google treats each tag, how to generate a sitemap on common platforms, and how to submit it.
What a sitemap does and doesn't do
A sitemap helps with discovery. It's especially useful when:
- Your site is large, so some pages are several clicks from the homepage.
- Your site is new and has few external links pointing to it.
- You publish or update content often.
- Some pages aren't well linked internally.
What a sitemap won't do:
- It won't guarantee indexing. Search engines still decide whether each page is worth indexing.
- It won't fix poor internal linking. Pages that matter should also be linked from other pages.
- It won't override other signals. A URL listed in a sitemap but marked
noindex, blocked by robots.txt, or redirected sends mixed signals.
Small sites with solid internal linking can get crawled fine without one, but a sitemap rarely hurts and it makes monitoring indexing in Search Console easier.
The basic format
Here's a minimal, valid sitemap with two URLs:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2026-09-01</lastmod>
</url>
<url>
<loc>https://www.example.com/guides/tent-sizes/</loc>
<lastmod>2026-08-14T09:30:00+00:00</lastmod>
</url>
</urlset>
The required pieces are:
- The
<urlset>element with the sitemaps.org namespace - One
<url>element per page - A
<loc>element inside each<url>with the page's full URL
The protocol also defines three optional tags: <lastmod>, <changefreq> and <priority>. More on how Google treats them below.
Formatting rules
- Use UTF-8 encoding.
- Escape special characters. An ampersand in a URL must be written as
&. The same applies to<,>, and quote characters. - Use absolute URLs. Google's sitemap guidelines ask for fully qualified URLs like
https://www.example.com/page/, not/page/. - Stay on one host and protocol. A sitemap on
https://www.example.com/should list onlyhttps://www.example.com/URLs. - Mind the location. Per the protocol, a sitemap at
/catalog/sitemap.xmlcan only list URLs under/catalog/. Putting sitemaps at the root avoids this limitation.
Size limits and sitemap indexes
A single sitemap file can contain at most 50,000 URLs and must be no larger than 50 MB uncompressed. You can gzip the file to save bandwidth, but the limit applies to the uncompressed size.
If you need more than that, split your URLs across several sitemaps and list them in a sitemap index file:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-pages.xml</loc>
<lastmod>2026-09-01</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-products-1.xml</loc>
<lastmod>2026-09-10</lastmod>
</sitemap>
</sitemapindex>
Splitting by content type is useful even on smaller sites, because Search Console reports on each submitted sitemap separately. If your product sitemap shows far fewer indexed pages than your blog sitemap, that's a clear place to investigate.
How Google treats lastmod, priority and changefreq
lastmod: use it, and keep it honest
Google says it uses <lastmod> when the value is consistently and verifiably accurate. It should reflect the last significant change to the page, such as updated main content, structured data or links. It shouldn't change because a copyright year in the footer rolled over or a sidebar widget refreshed.
Use the W3C Datetime format: either a date (2026-09-01) or a full timestamp with time zone (2026-09-01T14:05:00+00:00).
The most common problem is a sitemap generator that sets every lastmod to the current time on every build. When every page claims to have changed today, the value stops meaning anything.
priority and changefreq: skip them for Google
Google states that it ignores <priority> and <changefreq>. Other search engines may treat them as hints, so they do no harm, but don't spend time tuning them for Google.
What to include and what to leave out
A good sitemap contains only URLs you'd want to appear in search results:
Include:
- Canonical URLs that return a
200status - Pages that are indexable (no
noindex) - Pages allowed by robots.txt
Leave out:
- URLs that redirect
- URLs returning
404,410or server errors - Pages with
noindex - Non-canonical duplicates, such as tracking-parameter or sorted versions of a page
- Thin utility pages like cart, checkout, login and internal search results
A sitemap full of redirects and errors isn't fatal, but it makes your reports noisy and wastes crawl attention.
How to create a sitemap
WordPress
WordPress has included a basic built-in sitemap at /wp-sitemap.xml since version 5.5. SEO plugins such as Yoast SEO and Rank Math replace it with their own, usually at /sitemap_index.xml, and give you options to exclude post types, taxonomies or individual pages.
Shopify and other hosted platforms
Hosted platforms like Shopify generate /sitemap.xml automatically. Your job is mostly to make sure pages you don't want indexed are excluded or set to noindex.
Static sites and frameworks
Most static site generators and web frameworks have sitemap packages or plugins. If yours doesn't, generating one is simple. Here's a short Python example that builds a sitemap from a list of URLs and dates:
from xml.sax.saxutils import escape
pages = [
("https://www.example.com/", "2026-09-01"),
("https://www.example.com/guides/tent-sizes/", "2026-08-14"),
]
lines = ['<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">']
for loc, lastmod in pages:
lines.append(f" <url><loc>{escape(loc)}</loc><lastmod>{lastmod}</lastmod></url>")
lines.append("</urlset>")
with open("sitemap.xml", "w", encoding="utf-8") as f:
f.write("\n".join(lines))
The key is pulling lastmod from the date the content actually changed, such as a database updated_at field, rather than the build time.
Special sitemap types
The protocol can be extended for images, videos and news content, and sitemaps can also carry hreflang annotations for multilingual sites. Start with a standard URL sitemap and add these only if they apply.
How to submit your sitemap
1. Reference it in robots.txt
Add a line with the full URL anywhere in your robots.txt:
Sitemap: https://www.example.com/sitemap_index.xml
Any crawler that reads robots.txt can find it this way. See the robots.txt guide for details, and check the file with our Robots.txt Checker.
2. Submit it in Google Search Console
- Open your property in Google Search Console.
- Go to Indexing > Sitemaps.
- Enter the sitemap URL and click Submit.
Google's Sitemaps report documentation describes the statuses you'll see: Success means the file was read without errors, Couldn't fetch means Google couldn't retrieve it (often a robots.txt block or server problem), and Has errors means it was fetched but contains problems. URLs without errors are still processed.
Submit your sitemap index rather than every child sitemap. Google will discover the rest from the index.
3. Submit to Bing too
Bing Webmaster Tools has its own sitemap submission. It's a quick step that makes sure Bing, and the services that use its index, find your pages.
Google retired its old anonymous sitemap "ping" URL in 2023, so Search Console and robots.txt are the reliable routes.
Check it before and after
Before submitting, run your sitemap through our Sitemap Checker to catch malformed XML, unescaped characters, and URLs that redirect or return errors. After submitting, revisit the Sitemaps report and the Pages report in Search Console a few days later to see how many listed URLs are indexed and why the rest aren't.
Sitemap checklist
- Valid XML, UTF-8, with the sitemaps.org namespace
- Absolute URLs on the same host and protocol
- At most 50,000 URLs and 50 MB uncompressed per file
- A sitemap index for anything larger
- Only canonical, indexable,
200URLs lastmodthat reflects real content changes- Listed in robots.txt and submitted in Search Console and Bing Webmaster Tools
A sitemap is a small file, but when it's accurate it gives search engines a trustworthy map of your site, and gives you a clear view of what is and isn't being indexed.