Home / Fix guides / Technical SEO

How to create an XML sitemap for your website

An XML sitemap is a file, usually at /sitemap.xml, that lists the pages you want search engines to find. Most platforms can generate one automatically, and once it exists you submit it in Google Search Console.

A sitemap is a list of your important web pages, written in a format search engines can read. If your site has none, nothing is visibly broken. Visitors never see the file. The problem only shows up when you open yoursite.com/sitemap.xml and get a "404 not found" page, or when Google Search Console says "Sitemap could not be read" or "Couldn't fetch".

What a missing sitemap looks like

The usual signs are:

  • Visiting https://yourdomain.com/sitemap.xml shows an error page or your homepage instead of a block of XML code.
  • The Sitemaps report in Google Search Console is empty, because nobody ever submitted one.
  • New pages take a long time to appear in Google, or some pages never appear.
  • Your robots.txt file has no Sitemap: line.

Why it matters

Search engines find pages by following links. On a small, well linked site they will usually find most pages anyway. A sitemap helps most when your site is new (few other sites link to it), large, updated often, or has pages that are hard to reach by clicking around, such as products deep in a shop.

A sitemap does not guarantee a page is indexed, and it does not improve rankings by itself. What it does is give search engines a clean, complete list of the pages you care about, and it gives you a report in Search Console showing which of those pages were actually picked up. For a business that sells or takes bookings online, a page that Google never finds is a page that never brings in a customer.

How to check if your site has one

These checks are free and take a few minutes.

  1. Type https://yourdomain.com/sitemap.xml into your browser. You should see a list of web addresses wrapped in tags, or a list of further sitemap files.
  2. If that fails, try /sitemap_index.xml and /wp-sitemap.xml. Different platforms use different names.
  3. Open https://yourdomain.com/robots.txt and look for a line starting with Sitemap:. It often points to the real location.
  4. In Google Search Console, open Indexing, then Sitemaps. If the list of submitted sitemaps is empty, none has been submitted.

A sitemap can exist but not be submitted, and that is fine to fix in two minutes. It can also be submitted but broken. If Search Console reports an error on a sitemap you already submitted, see sitemap couldn't be fetched.

How to create an XML sitemap

There are three routes, from easiest to most manual.

1. Let your platform do it. Most website builders and shop platforms generate and update the sitemap for you. Often it only needs switching on.

2. Use an SEO plugin or package. If your platform does not do it natively, a well known SEO tool or library can generate one and keep it current as you add pages.

3. Write or generate it by hand. For a small static site with a handful of pages, you can create the file yourself. 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://www.example.com/</loc>
    <lastmod>2026-11-01</lastmod>
  </url>
  <url>
    <loc>https://www.example.com/contact/</loc>
  </url>
</urlset>

Save it as sitemap.xml in the root folder of your website so it loads at https://www.example.com/sitemap.xml. Only <loc> is required. Google ignores priority and changefreq, and uses lastmod only if it is accurate, so leave it out rather than guess.

One file can hold up to 50,000 addresses or 50 MB uncompressed. Bigger sites split the list into several files and tie them together with a sitemap index file.

Common platforms

Menu names change between versions and themes, so treat these as pointers for where to look.

PlatformWhat usually happens
WordPressRecent versions create /wp-sitemap.xml by default. SEO plugins such as Yoast SEO or Rank Math create their own, usually /sitemap_index.xml.
ShopifyCreated automatically at /sitemap.xml. You cannot edit it directly.
WebflowLook in Site settings, SEO, for the option to auto generate a sitemap, then publish the site.
Squarespace and WixCreated automatically at /sitemap.xml.
GhostCreated automatically at /sitemap.xml.
Next.jsAdd a sitemap.ts (or sitemap.js) file to the app folder, or use a package such as next-sitemap.
LaravelUsually done with a package such as spatie/laravel-sitemap, run on a schedule.
MagentoLook under Stores, Configuration, Catalog, XML Sitemap to enable it, then generate it from Marketing, SEO and Search, Site Map.

Step by step guides: WordPress, Shopify, Webflow, Next.js, Laravel, Magento and Ghost.

What to include, and what to leave out

List only pages you want to appear in search: real pages that load normally, use your preferred address (one version with or without www, always https), and are not blocked. Leave out login pages, thank you pages, internal search results, test pages and anything marked noindex. A sitemap full of redirects, errors or noindex pages sends mixed signals. If Search Console complains about this, read sitemap contains noindex URLs.

Submit it

  1. Add the line Sitemap: https://www.example.com/sitemap.xml to your robots.txt file, using your own full address.
  2. In Google Search Console, open Indexing, then Sitemaps.
  3. Type the sitemap path (for example sitemap.xml) and press Submit.
  4. Optionally, do the same in Bing Webmaster Tools.

Confirm the fix worked

  • The sitemap address loads in your browser and shows XML, not an error page.
  • Search Console shows the sitemap with the status "Success" and a count of discovered pages. This can take a few hours to a few days to appear.
  • The discovered page count roughly matches the number of pages you expect. A count of zero or far too few means something is wrong with the file.
  • Over the following weeks, the page indexing report shows more of your pages as indexed. A page being listed does not force Google to index it.

Stop it coming back

Sitemaps usually disappear because of a platform change: switching themes, removing an SEO plugin, rebuilding the site, or moving to a new host. After any of those, open /sitemap.xml again. Prefer an automatic sitemap over a hand written one, so new pages are added without anyone remembering to do it. If you must keep a manual file, add "update the sitemap" to your checklist for launching new pages.

Also check the sitemap address after any change to your www or https setup, and make sure your robots.txt is not blocking it.

SiteMonday checks for a missing sitemap in week 1, the SEO review, and reports it with a ranked fix list. Fixing it is still up to you or your developer.

Step by step for your platform

Questions

Where should my XML sitemap be located?

Most commonly at `/sitemap.xml` in the root of your site, for example `https://www.example.com/sitemap.xml`. Some platforms use another name, such as `/sitemap_index.xml` or `/wp-sitemap.xml`, so check your `robots.txt` for the exact address.

Do I need a sitemap if my site is small?

A small site with good internal links is usually found without one. A sitemap is still cheap to add, and it gives you a useful report in Google Search Console.

Will an XML sitemap make my site rank higher?

No. It helps search engines discover your pages but does not boost rankings, and it does not guarantee a page is indexed.

How often should I update my sitemap?

It should update whenever you add, remove or change pages, which is why an automatic sitemap is the better choice. Hand made files go out of date quickly.

Do I have to submit the sitemap to Google?

Not strictly, since Google can find it through a `Sitemap:` line in `robots.txt`. Submitting it in Search Console is still recommended because it shows you errors and page counts.

What is the difference between an XML sitemap and an HTML sitemap?

An XML sitemap is written for search engines and is not meant to be read by visitors. An HTML sitemap is an ordinary page of links for people. You can have both, but the XML one is what you submit to search engines.

Related problems