How to Find Your Magento 2 Sitemap

Magento 2 has built-in sitemap generation, but it doesn't work automatically out of the box. Unlike platforms that create sitemaps by default, Magento requires you to configure and generate your sitemap manually—or set up a cron job to do it automatically. This article covers where Magento stores sitemaps, how to generate them, and what to do when things go wrong.

Magento 2 Sitemap Location

When properly configured, Magento 2 generates sitemaps in your site's root directory:

https://yourdomain.com/sitemap.xml

However, you can customize both the filename and directory during sitemap configuration. If the default URL returns a 404, your sitemap might be named differently or stored in a subdirectory, or it might not exist at all yet.

Checking If Your Sitemap Exists

Before troubleshooting, verify whether Magento has actually generated a sitemap.

Through the Admin Panel

  1. Log in to your Magento Admin
  2. Navigate to Marketing → SEO & Search → Site Map
  3. This screen lists all configured sitemaps with their paths and generation status

If you see entries here, click on one to view its settings, including the exact path where the file is stored. The "Last Generated" column tells you when the sitemap was last created.

If this screen is empty, no sitemaps have been configured yet—which explains the 404.

Through File Manager or SSH

Connect to your server and check the Magento root directory for sitemap files:

bash

ls -la /path/to/magento/pub/sitemap*.xml ls -la /path/to/magento/sitemap*.xml

Magento can place sitemaps in either the main root or the pub directory, depending on your server configuration and sitemap settings.

Creating a Sitemap in Magento 2

If no sitemap exists, you'll need to create one.

Step 1: Configure Sitemap Settings

Go to Stores → Configuration → Catalog → XML Sitemap. Here you'll set global options that apply to all sitemaps:

Category Options

  • Frequency: How often category pages typically change (daily, weekly, etc.)
  • Priority: Relative importance of category pages (0.0 to 1.0)

Product Options

  • Frequency: Change frequency for product pages
  • Priority: Relative importance of products
  • Add Images into Sitemap: Include product images in the sitemap

CMS Pages Options

  • Frequency: Change frequency for CMS pages
  • Priority: Relative importance of static pages

Generation Settings

  • Enabled: Must be set to "Yes" for automatic generation
  • Start Time: When the daily cron job should run
  • Frequency: Daily, Weekly, or Monthly automatic generation
  • Error Email Recipient: Who receives notifications if generation fails

Save the configuration when finished.

Step 2: Create the Sitemap Entry

Navigate to Marketing → SEO & Search → Site Map and click "Add Sitemap." Fill in:

  • Filename: Usually sitemap.xml, but you can use any name
  • Path: The directory relative to the Magento root, typically / or /pub/
  • Store View: Select which store view this sitemap covers

For multistore setups, create separate sitemaps for each store view with distinct filenames like sitemap_en.xml and sitemap_de.xml.

Step 3: Generate the Sitemap

After saving the sitemap configuration, you'll return to the sitemap list. Find your new entry and click "Generate" in the Action column. Magento will create the XML file immediately.

If generation succeeds, the "Link for Google" column shows the full URL to your sitemap. Click it to verify the file exists and contains your URLs.

Automatic Sitemap Generation with Cron

Manual generation works for initial setup, but you want sitemaps to update automatically as products and content change.

Verify Cron Is Running

Magento relies heavily on cron jobs. Check that cron is configured and running:

bash

crontab -l

You should see an entry pointing to Magento's cron.php or the bin/magento cron:run command. If cron isn't configured, sitemaps won't regenerate automatically regardless of your settings.

Check Cron Configuration

In the admin, verify your generation settings under Stores → Configuration → Catalog → XML Sitemap → Generation Settings:

  • Enabled must be "Yes"
  • Frequency determines how often regeneration occurs
  • Start Time sets when the job runs (off-peak hours are best)

With these settings configured and cron running, Magento will regenerate your sitemap on schedule.

Understanding Magento 2 Sitemap Structure

Magento generates a single sitemap file by default, not a sitemap index. This file contains URLs for:

  • All enabled, visible products
  • All active categories (if enabled in settings)
  • All enabled CMS pages
  • Product images (if configured)

For stores with more than 50,000 URLs, Magento automatically splits the sitemap into multiple files and creates an index. You might see:

sitemap.xml (index file) sitemap-1-1.xml sitemap-1-2.xml

Controlling What's Included

Magento includes products based on visibility and status:

  • Visibility: Products set to "Catalog" or "Catalog, Search" appear in the sitemap
  • Status: Only "Enabled" products are included
  • Stock: By default, out-of-stock products are included (configurable)

Categories follow similar logic—only active categories with "Include in Navigation Menu" enabled appear by default.

To exclude specific products or categories, you'll need a third-party extension or custom development. Magento's native sitemap doesn't support individual URL exclusions.

Common Magento 2 Sitemap Issues

Sitemap Generation Fails Silently

If clicking "Generate" does nothing or the file isn't created:

Check file permissions: The target directory needs to be writable by the web server user. For the pub directory:

bash

chmod 775 /path/to/magento/pub chown www-data:www-data /path/to/magento/pub

Check disk space: Sitemap generation fails if the server runs out of disk space.

Review Magento logs: Check var/log/system.log and var/log/exception.log for errors during generation.

Sitemap Is Empty or Has Few URLs

If your sitemap generates but contains far fewer URLs than expected:

Check product visibility: Products with visibility set to "Not Visible Individually" won't appear.

Verify store view assignment: Products must be assigned to the store view the sitemap covers.

Check category settings: If categories are missing, ensure they're active and set to include in the menu.

Review indexers: Run bin/magento indexer:reindex to ensure product data is current.

Sitemap URL Doesn't Match Your Domain

If the sitemap contains URLs with the wrong domain (like localhost or an old staging domain):

Go to Stores → Configuration → General → Web and verify:

  • Base URL matches your production domain
  • Secure Base URL is set correctly

After fixing, regenerate the sitemap.

Cron Isn't Updating the Sitemap

If manual generation works but automatic updates don't:

Verify cron is running: Check cron_schedule table in the database for recent entries:

sql

SELECT * FROM cron_schedule WHERE job_code LIKE '%sitemap%' ORDER BY scheduled_at DESC LIMIT 10;

Check for stuck jobs: Clear old cron entries if the schedule is backed up:

bash

bin/magento cron:remove bin/magento cron:run

Review cron user permissions: The cron user needs write access to the sitemap directory.

Multistore and Multisite Sitemaps

For Magento installations with multiple store views or websites, best practice is creating separate sitemaps for each.

One Sitemap Per Store View

Create individual sitemaps like:

  • sitemap_us.xml for US English store
  • sitemap_uk.xml for UK English store
  • sitemap_de.xml for German store

Each sitemap generates URLs with that store view's base URL and includes only products/categories assigned to that view.

Sitemap Index for Multiple Sitemaps

Some SEO extensions add sitemap index functionality, letting you reference all store sitemaps from a single index file. Native Magento doesn't do this automatically across store views—only for splitting large single-store sitemaps.

Adding Your Sitemap to Robots.txt

Magento's robots.txt is a physical file in the root or pub directory. Add your sitemap reference manually:

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

For multistore setups with different domains, each domain's robots.txt should reference only that store's sitemap.

Some Magento SEO extensions can manage robots.txt through the admin panel, making this easier to maintain.

Submitting Your Magento Sitemap to Search Engines

Once your sitemap generates correctly:

Google Search Console: Navigate to Sitemaps, enter your sitemap URL, and submit. Google will report processing status and any errors encountered.

Bing Webmaster Tools: Go to Configure My Site → Sitemaps and add your URL.

Monitor these dashboards after submission. Large Magento catalogs sometimes have products with issues (malformed URLs, redirect chains) that only surface when search engines process the sitemap.