Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

How to Create an XML Sitemap (Step by Step)

Want to create an XML sitemap for your website? Most platforms make one for you, and for every other site you can generate one in a few minutes without installing anything. This guide shows how to find or create a sitema

Want to create an XML sitemap for your website? Most platforms make one for you, and for every other site you can generate one in a few minutes without installing anything. This guide shows how to find or create a sitemap on WordPress, Shopify, Wix, Squarespace and Blogger, and how to make one for a custom-built website.

Before you start: does your site already have a sitemap?

Many website builders and CMSs create a sitemap automatically. Before making a new one, open https://yourdomain.com/sitemap.xml in your browser, or enter your domain in a free sitemap finder, which checks robots.txt and 30 common locations at once.

How to create a sitemap on popular platforms

Platform Sitemap address What you need to do
WordPress (built-in) /wp-sitemap.xml Nothing. WordPress 5.5 and newer create it automatically.
WordPress + Yoast SEO /sitemap_index.xml Turn on XML sitemaps in Yoast's settings (on by default).
WordPress + Rank Math /sitemap_index.xml Enable the Sitemap module.
Shopify /sitemap.xml Nothing. Created and updated automatically.
Wix /sitemap.xml Nothing. Generated once your site is published.
Squarespace /sitemap.xml Nothing. Generated automatically.
Blogger /sitemap.xml Nothing. Blogger publishes one for your posts.

If your platform already makes a sitemap, skip to submitting it to Google Search Console. If not, or if you have a custom, static or hand-coded website, use one of the methods below.

Method 1: Use a free sitemap generator

This is the fastest way for any website. A crawler-based XML sitemap generator visits your site like a search engine and builds the file for you:

  1. Enter your homepage address, for example https://example.com. Use the exact version visitors see: https, and with or without www.
  2. Choose your options. Set the maximum number of pages, keep the last modified date on, and include images if they matter for your site.
  3. Generate the sitemap. Redirects, error pages and noindex pages should be left out.
  4. Download sitemap.xml.

Method 2: Build a sitemap from a list of URLs

If your site can't be crawled (it's behind a login, still in development, or its links load with JavaScript), build the sitemap from a list instead: paste one full URL per line into a generator that accepts a list, and download the file. Every URL should be the final address you want in Google.

Method 3: Write the sitemap by hand

For a very small site you can write the file in any text editor. Save it as sitemap.xml with UTF-8 encoding:

<?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-11-20</lastmod>
  </url>
  <url>
    <loc>https://example.com/services</loc>
    <lastmod>2026-11-01</lastmod>
  </url>
</urlset>

Write special characters correctly: an & in a URL must be written as &amp;, or the whole file becomes invalid.

Step 4: Upload the sitemap

  1. Open your hosting file manager or FTP client (cPanel, Plesk, FileZilla and similar).
  2. Upload sitemap.xml to your root folder, usually public_html or www, so it opens at https://yourdomain.com/sitemap.xml.
  3. Open that address in your browser and check it shows XML, not an error page.

Step 5: Check the sitemap for errors

One mistake can stop Google from reading the whole file. Run it through a sitemap checker that validates the XML, every URL and every date, and can test a sample of the listed pages for errors, redirects and noindex tags.

Step 6: Tell search engines about it

Submit the sitemap in Google Search Console and Bing Webmaster Tools, and add a Sitemap: line to your robots.txt so every search engine can find it:

Sitemap: https://yourdomain.com/sitemap.xml

Keep your sitemap up to date

A sitemap is only useful if it matches your site. WordPress and Shopify update theirs automatically. For custom or static sites, generate a new sitemap whenever you add, remove or rename pages, and upload it in place of the old one.

This guide was first published on XMLSitemapGenerator, where you'll also find free tools to create, check and find sitemaps.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.