How to Create an XML Sitemap for Your Website
By SimpleTools24Published 3 min read
To create an XML sitemap, list the canonical URLs of the pages you want search engines to find, write them into a sitemap.xml file using the standard sitemap format, publish the file on your site (usually at https://example.com/sitemap.xml), and tell search engines where it is. Most content management systems can generate one automatically; otherwise a sitemap generator can crawl your site or build the file from a list of URLs you paste in.
In this guide
What an XML Sitemap Is For
A sitemap is a machine-readable list of URLs you'd like search engines to crawl. It helps them discover pages, especially on new sites with few external links, large sites, or pages that aren't well linked internally. It doesn't guarantee indexing or improve rankings by itself. Search engines still decide what to crawl and index based on quality, canonicalisation and many other signals.
The Basic Format
A minimal sitemap looks like this:
<?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-07</lastmod>
</url>
<url>
<loc>https://example.com/tools/json-to-excel-converter</loc>
</url>
</urlset>Key rules from the sitemap protocol:
- The file must be UTF-8 encoded.
- Each
<loc>must be an absolute URL, includinghttps://. - Special characters such as
&must be escaped (&). - A single sitemap can hold up to 50,000 URLs and 50 MB uncompressed. Larger sites split URLs across several sitemaps listed in a sitemap index file.
<lastmod>is optional; Google says it uses it when it's consistently accurate.<priority>and<changefreq>are also defined by the protocol, but Google ignores them.
What to Include (and Leave Out)
Include:
- Pages you want to appear in search results
- The canonical version of each URL (one per page)
- URLs that return HTTP 200
Leave out:
- Redirecting URLs, 404s and error pages
- Pages marked
noindex - Duplicate URLs with tracking parameters, session IDs or sort orders
- Pages blocked by robots.txt
- Login, cart and internal search results pages
A clean sitemap is a strong signal of what you consider important. XML sitemap best practices covers these choices in more detail.
Method 1: Use Your CMS or Framework
Check whether you already have a sitemap before making another one:
- WordPress generates
/wp-sitemap.xmlby default, and SEO plugins such as Yoast or Rank Math replace it with their own. - Shopify, Wix and Squarespace create sitemaps automatically.
- Frameworks such as Next.js can generate a sitemap from code, so it updates with every deployment.
Try visiting /sitemap.xml, /sitemap_index.xml and /wp-sitemap.xml on your domain, and look for a Sitemap: line in /robots.txt. An automatically maintained sitemap is almost always better than a static file you have to remember to regenerate.
Method 2: Crawl Your Site With a Generator
If your platform doesn't produce a sitemap, a crawler can build one by following your internal links. The XML sitemap generator crawls a public website from its home page:
- Enter your site's URL and start the crawl.
- The crawler follows links on the same host, respects robots.txt, and skips non-HTML resources.
- Review the discovered URLs. Remove anything that shouldn't be there, such as filtered or duplicate pages.
- Download
sitemap.xml. Large lists are split into multiple files with an index.
Each crawl covers up to 1,000 pages. Pages that nothing links to can't be found by crawling, which is a good reason to also check your internal linking.
Method 3: Build It From a List of URLs
If you already know your URLs, for example from a CMS export, analytics or a spreadsheet, use the generator's Paste URLs mode. Paste the addresses or upload a TXT or CSV file; the tool validates them, removes duplicates and builds the XML in your browser without crawling anything.
Publish the File
- Upload
sitemap.xmlto your site's root, so it's available athttps://yourdomain.com/sitemap.xml. A sitemap can only list URLs at or below its own location, so the root is the safest place. - Open the URL in a browser to confirm it loads and returns the XML.
- Add a line to
robots.txt:
Sitemap: https://yourdomain.com/sitemap.xml- Submit it in Google Search Console and Bing Webmaster Tools. How to submit a sitemap to Google Search Console walks through that.
Frequently Asked Questions
Do small websites need a sitemap?
Not strictly; a small, well-linked site is usually discovered without one. A sitemap still helps search engines find new pages quickly and makes Search Console reporting clearer.
Does a sitemap improve rankings?
No. It helps with discovery. Ranking depends on content and many other factors.
Can I have more than one sitemap?
Yes. List them in a sitemap index file, or submit each one separately.
Should images be in my sitemap?
Optional. Google supports image sitemap extensions, but images on pages it crawls are usually found anyway.
Summary
Use your CMS's sitemap if it has one. Otherwise, crawl your site or paste a URL list into a generator, include only canonical, indexable 200-status pages, publish at the root and submit it to search engines.
Related tools
Sources
- Build and submit a sitemap – Google Search Central (opens in a new tab)
- Sitemaps XML format – sitemaps.org (opens in a new tab)
Related articles
- Submit a Sitemap to GoogleSubmit a sitemap in Search Console, read the report correctly, and make sure Bing and others can find it too.
- XML Sitemap Best PracticesWhat belongs in a sitemap, how to use lastmod, size limits and index files, and the mistakes that weaken it.
- XML vs HTML SitemapXML sitemaps feed crawlers, HTML sitemaps help visitors. When each one is worth having.