Docs

Add a sitemap

Add a sitemap

A sitemap is an XML file that lists the site's pages, often with the date each one last changed. Google finds pages by following links anyway, but a sitemap gets new and changed pages crawled sooner, and it reaches pages that few links point to: products deep in a shop, old blog posts, landing pages that are not in the menu. In Google Search Console it also shows how many of the listed pages are actually indexed.

The site checklist marks a missing sitemap as Check. It is not an emergency, but on most sites it takes a few minutes to set up.

What the checklist looks for

We look in two places, in this order:

  1. https://example.com/sitemap.xml (a redirect to another address is fine);
  2. the first Sitemap: line in robots.txt, for sitemaps at other addresses, such as /sitemap_index.xml or /wp-sitemap.xml.

The file has to return 200 and be a real sitemap: an <urlset> (a list of pages) or a <sitemapindex> (a list of sitemaps). A home page returned for any unknown address does not count.

Check it yourself

Replace example.com with your site:

curl -sL https://example.com/sitemap.xml | head -c 400
curl -sL https://example.com/robots.txt | grep -i '^sitemap:'

The first command should print XML with <urlset or <sitemapindex in it. If it prints HTML or an error, the second one shows whether robots.txt points elsewhere. One of the two is enough.

How to fix

Most systems already make a sitemap, and the fix is to turn it on or point to it. Point to it from robots.txt with one line anywhere in the file, using the full address:

Sitemap: https://example.com/sitemap_index.xml

WordPress

WordPress has had a built-in sitemap since version 5.5, at /wp-sitemap.xml. /sitemap.xml redirects to it, and the generated robots.txt lists it. It is switched off when Settings → Reading → Search engine visibility is ticked, which is one more reason to untick it on a live site.

SEO plugins replace it with their own, at /sitemap_index.xml:

  • Yoast SEO: Yoast SEO → Settings → Site features, turn on XML sitemaps.
  • Rank Math: Rank Math SEO → Dashboard → Modules, turn on Sitemap; settings are under Rank Math SEO → Sitemap Settings.

Use one sitemap, not two. If /sitemap.xml still returns a 404 after you turn one on, go to Settings → Permalinks and click Save Changes (it refreshes the rewrite rules), and clear the page cache. If the site has a physical robots.txt file, add the Sitemap: line to it yourself.

cPanel

A hosting panel does not make sitemaps; the CMS or a generator does. If the site is plain HTML, generate sitemap.xml with a sitemap generator tool, then upload it with Files → File Manager into the site's root folder (usually public_html), next to index.html. Add the Sitemap: line to robots.txt in the same folder.

Remember to regenerate the file when you add pages. For a site that changes often, a CMS or app that builds the sitemap itself is the better option.

Node.js and Next.js

In the Next.js App Router, add app/sitemap.js; Next.js serves it at /sitemap.xml:

export default async function sitemap() {
    const posts = await getPosts(); // your data

    return [
        { url: 'https://example.com/', lastModified: new Date() },
        ...posts.map((post) => ({
            url: `https://example.com/blog/${post.slug}`,
            lastModified: post.updatedAt,
        })),
    ];
}

Point to it from app/robots.js with sitemap: 'https://example.com/sitemap.xml'. For the Pages Router or other frameworks, a build step that writes public/sitemap.xml does the same job.

Laravel

The spatie/laravel-sitemap package builds a sitemap from your models or by crawling the site:

composer require spatie/laravel-sitemap
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;

Sitemap::create()
    ->add(Url::create('/'))
    ->add(Post::all())   // the model implements Sitemapable
    ->writeToFile(public_path('sitemap.xml'));

Run it from a scheduled command (daily is plenty) so new pages appear on their own, and add the Sitemap: line to public/robots.txt.

Static HTML

Write sitemap.xml in the site's root, one <url> per page:

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

Use full addresses with the same https:// and www (or no www) as the live site. A static site generator (Hugo, Eleventy, Astro, Jekyll) can produce this file on every build.

Shopify

Shopify makes the sitemap itself, at /sitemap.xml, and lists it in robots.txt. There is nothing to turn on. If the checklist cannot find it, check that the store is not password protected (Online Store → Preferences).

Wix

Wix makes the sitemap itself, at /sitemap.xml, once the site is published on a domain. Pages hidden from search engines are left out of it.

Webflow

Open Site settings → SEO, turn on Auto-generate sitemap, and Publish. The sitemap is at /sitemap.xml and is rebuilt on every publish.

Squarespace

Squarespace makes the sitemap itself, at /sitemap.xml. There is nothing to turn on.

Tell Google

After the sitemap exists, submit it once in Google Search Console: Indexing → Sitemaps, enter the address (for example sitemap_index.xml) and click Submit. The report then shows when Google last read it and how many of its pages are indexed. Bing Webmaster Tools has the same under Sitemaps.

A sitemap should list only pages you want in search: the live address of each, returning 200, without noindex. A sitemap full of redirects and 404s teaches Google to trust it less.

Confirm the fix

Run the two curl commands from Check it yourself again, then open the target in PulseKeeper and click Check now on the Checklist tab. The item turns OK within a few minutes instead of at the next daily run.