Check 03.06 · Crawling

Generate the XML sitemap automatically

Set up an XML sitemap that updates itself on every publication on WordPress, Shopify, PrestaShop, Magento, Drupal, Laravel, Symfony, Next.js, Nuxt or Astro.

Priority
Critical
Difficulty
Intermediate
Estimated time
30 min to 3 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

An XML sitemap lists the URLs you want crawled and indexed. It is only useful if it stays accurate: a published page must go in, a deleted page must come out, a modified page must get a new date. This check consists of handing its production to the CMS or the application, based on the content actually published, rather than relying on a one-off export. Expected result: a file, or an index of files, that reflects the site with no manual intervention, with absolute URLs and a reliable lastmod date.

Why it matters

Crawlers mostly discover pages through links. The sitemap complements this mechanism for recent, deep or poorly linked pages, and gives search engines a last modification date. Google uses it if the values are “consistently and verifiably accurate”; Bing uses it to decide which pages to recrawl and may skip those that have not changed.

A frozen sitemap has the opposite effect. Generated once with an online tool and then forgotten, after a few months it lists deleted pages and redirected URLs, and misses everything new. Search engines lose a useful signal, and the Search Console and Bing Webmaster Tools reports surface errors that hide the real problems.

For generative engines, the effect is indirect: AI Overviews and Copilot rely on the Google and Bing indexes, which the sitemap helps keep up to date. A page discovered sooner is not necessarily cited.

Google says it ignores the <priority> and <changefreq> tags, and so does Bing. Only the URL (<loc>) and the date (<lastmod>) count, plus the image, video, news and language version extensions if you need them.

What it improves

  • Discovery New pages are announced as soon as they are published, without waiting for a link to lead to them.
  • Recrawling An accurate lastmod steers Google and Bing toward the pages that really changed.
  • Diagnostics The indexing report filtered by sitemap shows the status of only the URLs you consider important.
  • Large sites and new sites The clearest effect. On a small, well-linked site, the gain is small.
  • Rankings No direct effect.

How to check

1. Does the sitemap exist and generate itself?

curl -s -o /dev/null -w "%{http_code} %{content_type}\n" https://example.com/sitemap.xml
curl -s --compressed https://example.com/sitemap.xml | grep -c "<loc>"
curl -s --compressed https://example.com/sitemap.xml | grep -o "<lastmod>[^<]*" | sort -r | head -n 3

Publish a test page, then run the commands again: the number of <loc> entries must go up and the most recent date must match the publication (after the expected cache delay or scheduled task).

2. Are the URLs absolute and canonical? They must all start with https://example.com/: no http://, no staging host, no relative path.

curl -s --compressed https://example.com/sitemap.xml | grep -o "<loc>[^<]*" | grep -v "^<loc>https://example.com/" | head

3. What do search engines see? The Search Console Sitemaps report shows the status (“Success”, “Couldn't fetch”, “Has errors”), the date it was last read and the number of discovered URLs. Bing Webmaster Tools gives the same information in its Sitemaps section.

How to implement

Before you start

What an automatic sitemap must guarantee:

Criterion Rule
Source the published content in the database or CMS, not a crawl or a hand-made list
Updates on every publication, modification or deletion, or through a scheduled task at least daily
URLs absolute, on the canonical host and protocol, UTF-8 encoded, & characters escaped
Content only indexable pages returning 200 (see Include only indexable canonical URLs returning HTTP 200 (opens in a new tab))
lastmod date of the last significant change to the content, not the date the file was generated
Limits 50,000 URLs and 50 MB uncompressed per file; beyond that, a sitemap index
Location preferably at the root of the host: a sitemap only covers its folder and the folders below it, unless it is submitted in Search Console

Minimal format:

<?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-20T09:30:00+01:00</lastmod>
  </url>
  <url>
    <loc>https://example.com/guides/choisir-chaussures-trail</loc>
    <lastmod>2026-11-18T14:05:00+01:00</lastmod>
  </url>
</urlset>

Sitemap index, when you separate content types or exceed the limits:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemaps/pages.xml</loc>
    <lastmod>2026-11-20T09:30:00+01:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemaps/produits.xml</loc>
    <lastmod>2026-11-21T07:00:00+01:00</lastmod>
  </sitemap>
</sitemapindex>

One generator at a time. Two plugins, or a plugin plus the CMS's native sitemap, produce two competing files that are rarely consistent. Once the sitemap is in place, declare it in robots.txt (opens in a new tab).

Warning: do not write lastmod from the current time (new Date(), now()). Every URL would change date at each generation, and both Google and Bing would learn to ignore this field for the whole site.

WordPress

Versions WordPress 5.5 to 7.1 (native lastmod date since 6.5); Yoast SEO 20 to 28; Rank Math 1.0.

Since version 5.5, WordPress natively produces an index at /wp-sitemap.xml, with posts, pages, public content types, taxonomies and authors, and a lastmod date since version 6.5. It is disabled if the site asks search engines not to index it.

To remove author pages, often of no value on a single-author site, add this to a custom plugin:

add_filter('wp_sitemaps_add_provider', function ($provider, string $name) {
    if ($name === 'users') {
        return false;
    }

    return $provider;
}, 10, 2);

With an SEO plugin, use its sitemap and only its sitemap:

  • Yoast SEO: Yoast SEO > Settings > Site features, XML sitemaps toggle. Index at /sitemap_index.xml; the native sitemap is replaced and content types set to noindex are excluded.
  • Rank Math: Rank Math SEO > Sitemap Settings, with a setting per content type and per taxonomy. Index at /sitemap_index.xml.

Both generate the file on demand, from the database: it keeps up with publications with no scheduled task. Purge the page cache and the CDN for the sitemap URL, or exclude it from caching.

Shopify

Versions Shopify, all plans, November 2026.

Automatic. Shopify publishes /sitemap.xml, an index pointing to sitemaps of products, collections, blog posts and pages, updated on every addition. On a paid plan with international domains, each domain has its own sitemap and the languages sold are added to it. The sitemap cannot be edited; a password-protected store cannot be read by Google. To remove a resource, see exclusion through the seo.hidden metafield in the check on indexable canonical URLs.

PrestaShop

Versions PrestaShop 8 and 9; Google sitemap module (gsitemap) 4.4, or 5.0 from PrestaShop 8.2.

Install the “Google sitemap” module (gsitemap) from Modules > Module Manager, then open its configuration:

  1. tick the page types to include (products, categories, CMS pages, brands…);
  2. run the generation: the module writes one index per store at the root (1_index_sitemap.xml) and one file per language;
  3. copy the scheduled task URL shown by the module and schedule it with your host, for example every night:
0 3 * * * curl -s "https://example.com/module/gsitemap/cron?token=YOUR_TOKEN" > /dev/null

Copy the exact URL, token included, from the module's screen. Then regenerate robots.txt so that it declares the index.

Magento

Versions Magento Open Source and Adobe Commerce 2.4.7 to 2.4.9.

  1. Marketing > SEO & Search > Site Map, Add Site Map: file name sitemap.xml, path /, then Save & Generate.
  2. Stores > Settings > Configuration > Catalog > XML Sitemap, Generation Settings section: Enabled set to Yes, start time, Daily frequency.
  3. In the Categories Options, Products Options and CMS Pages Options sections, choose what is included; Add Images into Sitemap handles product images.
  4. Sitemap File Limits: 50,000 URLs and 10 MB per file by default; beyond that, Magento splits the URLs into several files. Check the file produced after the first generation.

Scheduled generation relies on Magento's cron: make sure it runs (bin/magento cron:run scheduled in the server's crontab), otherwise the file will never be updated.

Drupal

Versions Drupal 10.3 and later, Drupal 11; Simple XML Sitemap 4.x.

Install Simple XML Sitemap, compatible with Drupal 10.3 and 11:

composer require drupal/simple_sitemap
drush en simple_sitemap

Set the content types to include in Configuration > Search and metadata > Simple XML Sitemap, then, if needed, entity by entity in the edit form. The sitemap is served at /sitemap.xml and regenerated by Drupal's cron: make sure it runs (Configuration > System > Cron).

Joomla

Versions Joomla 5 and 6; OSMap 5.x.

Joomla has no native XML sitemap: you need an extension, for example OSMap, which builds the sitemap from menus and components. Choose an extension compatible with your Joomla version, publish the sitemap at a fixed URL and check that recent articles appear in it with no manual action.

Wix

Versions Wix editor and Wix Studio, all plans, November 2026.

Automatic: Wix publishes /sitemap.xml and updates it on every publication. Pages hidden from search engines in their SEO settings are removed from it.

Squarespace

Versions Squarespace 7.0 and 7.1, all plans, November 2026.

Automatic: /sitemap.xml is generated and updated by the platform, with no setting.

Webflow

Versions Webflow, all site plans, November 2026.

In Site settings > SEO, turn on automatic sitemap generation, then publish. Webflow adds static pages and published CMS collection items. A page excluded from indexing in its SEO settings must be removed from the sitemap through the page or collection setting.

Laravel

Versions Laravel 11 to 13; spatie/laravel-sitemap 7.3 and 8.x.

With spatie/laravel-sitemap, generate the file through a scheduled command, from published content. Composer installs version 8 on Laravel 12 and 13 with PHP 8.4 or later, version 7.3 otherwise; the code below works with both:

composer require spatie/laravel-sitemap
<?php

// app/Console/Commands/GenerateSitemapCommand.php
namespace App\Console\Commands;

use App\Models\Post;
use Illuminate\Console\Command;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;

class GenerateSitemapCommand extends Command
{
    protected $signature = 'generate-sitemap';

    protected $description = 'Write public/sitemap.xml from published content';

    public function handle(): void
    {
        $sitemap = Sitemap::create()->add(Url::create(route('home')));

        Post::query()
            ->where('is_published', true)
            ->orderBy('id')
            ->lazy()
            ->each(function (Post $post) use ($sitemap): void {
                $sitemap->add(
                    Url::create(route('posts.show', $post))
                        ->setLastModificationDate($post->updated_at)
                );
            });

        $sitemap->writeToFile(public_path('sitemap.xml'));

        $count = count($sitemap->getTags());

        $this->comment("Sitemap written with {$count} URLs.");
    }
}
<?php

// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('generate-sitemap')->hourly();

The scheduler only runs if the server's crontab launches php artisan schedule:run every minute. For an immediate update, also call the command from an event listener after each publication. Beyond 50,000 URLs, write one file per content type and group them with SitemapIndex. The package also offers a crawl-based generator (SitemapGenerator): it reflects the links, not the database, and includes whatever is linked even if it is not indexable.

updated_at also changes on minor modifications (view counter, technical status): if that is your case, store a content modification date in a dedicated column.

Symfony

Versions Symfony 6.4, 7.4 and 8.x; PrestaSitemapBundle 4.x.

With PrestaSitemapBundle (composer require presta/sitemap-bundle), populate the sitemap through a subscriber to the build event:

<?php

// src/EventListener/SitemapSubscriber.php
namespace App\EventListener;

use App\Repository\ArticleRepository;
use Presta\SitemapBundle\Event\SitemapPopulateEvent;
use Presta\SitemapBundle\Sitemap\Url\UrlConcrete;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class SitemapSubscriber implements EventSubscriberInterface
{
    public function __construct(private ArticleRepository $articles)
    {
    }

    public static function getSubscribedEvents(): array
    {
        return [SitemapPopulateEvent::class => 'populate'];
    }

    public function populate(SitemapPopulateEvent $event): void
    {
        $router = $event->getUrlGenerator();

        foreach ($this->articles->findPublished() as $article) {
            $url = $router->generate('article_show', ['slug' => $article->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);

            $event->getUrlContainer()->addUrl(new UrlConcrete($url, $article->getUpdatedAt()), 'articles');
        }
    }
}

The bundle serves /sitemap.xml on demand. For a large site, write the files to public/ through a scheduled task: bin/console presta:sitemaps:dump. The command always produces a sitemap.xml index and one file per section. Configure the router to generate absolute URLs from the command line (default_uri in config/packages/routing.yaml).

Next.js

Versions Next.js 15 and 16 (App Router).

Create app/sitemap.ts: Next.js serves the result at /sitemap.xml.

// app/sitemap.ts
import type { MetadataRoute } from 'next'

type Article = { slug: string; updatedAt: string }

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const response = await fetch('https://cms.example.com/api/articles?status=published', {
    next: { revalidate: 3600 },
  })
  const articles: Article[] = await response.json()

  return [
    { url: 'https://example.com/', lastModified: '2026-11-20' },
    ...articles.map((article) => ({
      url: `https://example.com/blog/${article.slug}`,
      lastModified: article.updatedAt,
    })),
  ]
}

The file is cached by default: hourly revalidation rebuilds it from the CMS. Beyond 50,000 URLs, export generateSitemaps() to produce several files (/blog/sitemap/0.xml, /blog/sitemap/1.xml…); since Next.js 16, the sitemap function receives id as a promise of a string (await props.id), whereas Next.js 15 passes it directly. The Next.js documentation provides no automatic index for these files: declare them in app/robots.ts, or serve an index through a route handler, and check the result for your version.

Nuxt

Versions Nuxt 4.6 and later; @nuxtjs/sitemap module 9.

Install the @nuxtjs/sitemap module, set the site URL and a source for dynamic content:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/sitemap'],
  site: { url: 'https://example.com' },
  sitemap: {
    sources: ['/api/__sitemap__/urls'],
  },
})
// server/api/__sitemap__/urls.ts
import { defineSitemapEventHandler } from '#sitemap/server'
import type { SitemapUrlInput } from '#sitemap/types'

export default defineSitemapEventHandler(async () => {
  const articles = await $fetch<{ slug: string; updatedAt: string }[]>('https://cms.example.com/api/articles')

  return articles.map((article) => ({
    loc: `/blog/${article.slug}`,
    lastmod: article.updatedAt,
  })) satisfies SitemapUrlInput[]
})

Static pages in app/pages/ (pages/ on Nuxt 3) are added automatically; the sitemap is served at /sitemap.xml. With versions 7 and 8 of the module, still used on Nuxt 3 and early Nuxt 4 releases, #sitemap/server does not exist: delete that import line, as defineSitemapEventHandler is auto-imported there.

Astro

Versions Astro 5 to 7; @astrojs/sitemap 3.x integration.

npx astro add sitemap
// astro.config.mjs
import { defineConfig } from 'astro/config'
import sitemap from '@astrojs/sitemap'

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    sitemap({
      filter: (page) => !page.includes('/merci/'),
    }),
  ],
})

The integration produces sitemap-index.xml and sitemap-0.xml at every build. It does not know about dynamic routes rendered on the server: for those, generate a sitemap through an endpoint. The sitemap is therefore only up to date if the site is rebuilt on every publication: trigger the build with a CMS webhook. For a per-page date, use the serialize() option.

Common mistakes

  • A sitemap produced once by an online generator: it goes stale with the first publication.
  • Two active generators: native sitemap and plugin sitemap, or two plugins. Search engines receive two contradictory lists.
  • lastmod equal to the generation time on every URL: the signal loses all value.
  • Generating by crawling the site: you get whatever is linked, including non-indexable pages, and miss orphan pages.
  • A scheduled task that does not run: Magento, Drupal or Laravel cron stopped, and the file stays out of date.
  • The sitemap cached for days by the CDN: exclude it from caching or give it a short lifetime.
  • Staging URLs (staging.example.com) because the base URL comes from the wrong environment variable.
  • Believing that priority and changefreq speed up indexing: Google and Bing ignore them.

Frequently asked questions

Is an XML sitemap required to get indexed?

No, a sitemap is not required: Google and Bing discover most pages through links. It becomes useful on a new, large or poorly linked site, and to signal changes through the lastmod date. On a small, well-linked site its effect is small, but an automatically generated sitemap costs almost nothing to maintain and makes diagnostics in Search Console easier.

How often should the sitemap be regenerated?

The sitemap should reflect the site as closely as possible: ideally on every publication, modification or deletion, otherwise through a scheduled task at least daily. CMSs such as WordPress, Shopify or Wix generate it on demand and need no scheduled task. On Magento, Drupal or Laravel, make sure the server's cron is running, otherwise the file stays frozen.

Are the priority and changefreq tags still useful?

No, Google says it ignores the priority and changefreq tags in sitemaps, and so does Bing. There is no point setting them page by page. The two pieces of information that count are the canonical URL in loc and the date of the last significant change in lastmod, which Google uses if it is consistently accurate and which Bing relies on to choose the pages to recrawl.

Should I have several sitemaps or just one?

A single sitemap is enough as long as it stays under 50,000 URLs and 50 MB uncompressed. Beyond that, or to track products, articles and pages separately, split it into several files grouped in a sitemap index. Splitting by content type then lets you filter the Search Console indexing report on each sitemap and spot a section that is falling behind.

Updated on

Topic checklist (PDF)

And now?

In the “Crawling” topic

  1. Check robots.txt access and syntax
  2. Allow Googlebot on strategic pages
  3. Allow Bingbot on strategic pages
  4. Allow required CSS/JS resources
  5. Declare sitemaps in robots.txt
  6. Generate the XML sitemap automatically
  7. Include only indexable canonical URLs returning HTTP 200
  8. Exclude redirects, errors and noindex pages
  9. Provide a reliable lastmod
  10. Split large sitemaps
  11. Stay within 50,000 URLs and 50 MB uncompressed per sitemap
  12. Submit sitemaps to Google and Bing
  13. Analyze crawl stats
  14. Analyze server logs
  15. Identify crawler traps
  16. Optimize crawl budget if warranted
  17. Check CDN, WAF and anti-bot protection
  18. Check that public pages are accessible without authentication
  19. Monitor DNS and server errors
  20. Set up IndexNow if relevant