How to create a sitemap.xml file

Crawvix Editorial Team · Published November 1, 2026 · Last updated November 1, 2026 · 2 min read

A sitemap.xml file is a text file in XML format that lists the public, canonical pages you want search engines to find. Generate it with your CMS or a plugin, or write it by hand with one url entry per page. Save it as sitemap.xml at your site root, then submit its address in Google Search Console.

Why it matters

A sitemap gives crawlers a clean list of the pages you care about. That is most useful for new sites, large sites and pages that few other pages link to. It does not force Google to index anything, but it also gives Search Console a place to report problems with the file.

How to do it

  1. Decide which pages belong. List only canonical pages that are meant to appear in search and return a normal 200 status. Leave out redirects, error pages, login pages and anything marked noindex.
  2. Check whether your platform already makes one. Many website builders and content management systems generate a sitemap automatically, so open /sitemap.xml on your domain first. WordPress itself publishes one at /wp-sitemap.xml.
  3. If you need to write one by hand, use this structure:
<?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-11-01</lastmod>
  </url>
  <url>
    <loc>https://www.example.com/about</loc>
  </url>
</urlset>
  1. Save the file as UTF-8 text named sitemap.xml in the top folder of your site, so it loads at https://www.example.com/sitemap.xml.
  2. Add a line to your robots.txt file so any crawler can find it:
Sitemap: https://www.example.com/sitemap.xml
  1. Open Search Console, choose your property, go to Sitemaps, enter the address and select Submit.

Each loc must be a full address that uses the same protocol and host as the pages themselves. Replace an ampersand inside an address with &amp;, because a raw one makes the XML invalid. A single sitemap may hold up to 50,000 URLs and 50 MB uncompressed.

Crawvix's scan checks that the sitemap is valid.

Common mistakes

  • Listing URLs that redirect, return errors or carry a noindex tag.
  • Mixing http and https, or www and non-www, in the same file.
  • Leaving an unescaped ampersand or stray text before the XML declaration.
  • Setting every lastmod to the day the file was generated instead of the date the page changed.
  • Forgetting to update the file when pages are added or removed.

Frequently asked questions

Do I need a sitemap?

Not strictly. Google can usually find well-linked pages without one. A sitemap is still worth having because it speeds up discovery of new pages and shows you errors in Search Console.

Can I use a sitemap generator?

Yes. Generators and plugins are fine as long as you open the output and check that it lists only the pages you want indexed.

Does the file have to be called sitemap.xml?

No, any name works, but sitemap.xml at the root is the convention and is easy for people and tools to find. Whatever you choose, submit the exact address.

Want to see how your own pages look to a crawler? Try the free website sample.

In this category

All 100 Quick answers guides