Magento 2 Setup Sitemap

Share this article, Choose your platform!

What Is a Magento 2 XML Sitemap?

An XML sitemap is a specialised file on your server that lists every important page on your website. Think of it as a roadmap created specifically for search engine “crawlers” like Googlebot.

In Magento 2, this file helps search engines find your products, categories, and CMS pages quickly. Without a sitemap, a search engine has to find your pages by following links. On a large e-commerce site, some pages might be buried too deep for a crawler to find. The Magento 2 XML sitemap ensures no page is left behind.

Why XML Sitemaps Matter for Magento 2 SEO

SEO for Magento 2 depends heavily on how efficiently Google can read your store. With over 170,000 websites using Magento, competition is high. Statistics show that websites using sitemaps see a 15% better indexation rate. This is vital for stores with deep catalogs.

Key benefits include:

  • Faster Indexing: New products show up in search results sooner.
  • The ‘Lastmod’ Signal: This tag tells Google exactly when a page was last updated. Google’s John Mueller confirms this is a “very strong signal” for recrawling.
  • Better Coverage: It ensures your “hidden” or deep-link categories are discovered.

Preparing Your Store for Sitemap Configuration

Before you start clicking buttons in the admin panel, you must ensure your server is ready.

  1. Server Permissions: Your Magento folder must allow the system to “write” files. If permissions are locked, the sitemap cannot be saved.
  2. Enable Cron Jobs: Automation relies on “cron jobs” scheduled tasks that run in the background. If your cron is not running, your sitemap will never update automatically.
  3. Base URL Check: Ensure your store URLs are configured correctly under Stores > Configuration > General > Web.

How to Configure Magento 2 XML Sitemap Settings

To begin, navigate to Stores > Settings > Configuration. On the left menu, go to Catalog > XML Sitemap.

Categories Options

This section controls how your category pages appear.

  • Frequency: How often does the category change? Usually, “Daily” or “Weekly” is best.
  • Priority: Set this between 0.0 and 1.0. Most stores set categories at 0.8 because they are high-value navigation hubs.

Products Options

Products are the lifeblood of your store.

  • Frequency: Set to “Daily” if you update stock or prices often.
  • Priority: Usually set to 1.0 for top products.
  • Include Images: Always set this to “All.” This helps your products appear in Google Image Search.

CMS Pages Options

These are your static pages like “About Us” or “Contact.”

  • Frequency: “Monthly” is usually enough.
  • Priority: Set to 0.2 or 0.5, as these are less important for sales than product pages.

Store URL Options

This handles your homepage settings. Since the homepage is your most important asset, it should always have a priority of 1.0 and a frequency of “Daily.”

Sitemap File Limits & Generation Settings

Google has limits: a single sitemap cannot exceed 50,000 URLs or 50MB. Magento 2 is smart enough to split these into “index files” if you go over. Ensure “Enabled” is set to “Yes.”

Search Engine Submission Settings

Set Enable Submission to Robots.txt to “Yes.” This automatically tells any search engine where to find your roadmap the moment they arrive at your site.

Step-by-Step: Manually Generating Your Magento 2 Sitemap

If you don’t want to wait for the automation, you can do it manually:

  1. Go to Marketing > SEO & Search > Site Map.
  2. Click Add Sitemap.
  3. Enter a filename (usually sitemap.xml) and the path (usually /).
  4. Click Save & Generate.
  5. Check the “Link for Google” column to verify the URL works.

Automating Magento 2 Sitemap Generation with Cron

Manual updates are easy to forget. Automation ensures Google always sees your latest products.

  • Generation Settings: Go back to Stores > Configuration > Catalog > XML Sitemap.
  • Enabled: Set to Yes.
  • Start Time: Choose a time when traffic is low (like 2:00 AM).
  • Error Email: Enter your email so you get an alert if the process fails.
Page Type Recommended Frequency Recommended Priority
Homepage Daily 1.0
Category Pages Daily/Weekly 0.8
Product Pages Daily 1.0
CMS Pages Monthly 0.5

Customisations & Advanced Tips

Splitting Sitemaps for Large Stores

If you have 100,000 products, Magento will create a “Sitemap Index.” This is a master file that points to smaller sitemaps. This keeps your site compliant with Google’s technical rules.

Adding Custom Links & Hreflang Tags

If you have a multi-language store, your sitemap should include hreflang tags. These tell Google which version of a page belongs to which country. While basic Magento handles this, some advanced SEO extensions provide more control.

Excluding Unwanted Pages

You don’t want “Thank You” pages or customer “Account” pages in your sitemap. Magento generally excludes these by default, but you should always check your “Noindex” settings for specific CMS pages to keep your sitemap clean.

Submitting & Verifying Your Sitemap in Search Engines

Adding to robots.txt

While the admin setting does this automatically, you can manually add this line to your robots.txt file:

Sitemap: https://www.yourstore.com/sitemap.xml

Submitting in Google Search Console

  1. Log into Google Search Console.
  2. Click Sitemaps in the left sidebar.
  3. Paste your sitemap URL and click Submit.
  4. Wait for the “Success” status to appear.

Troubleshooting Common Sitemap Issues

  • 404 Errors: If your sitemap link leads to a 404, check your file permissions. The server might not have permission to create the file.
  • Empty Sitemaps: If the file exists but is empty, try running a full reindex via the command line: php bin/magento indexer:reindex.
  • Cron Failures: If the sitemap isn’t updating, check your cron status. You can see this in your server’s terminal or via a “Cron Scheduler” extension.

Best Practices to Maximise Your Sitemap’s Effectiveness

To get the most out of your Magento 2 setup, follow these four golden rules:

  1. Always Include Images: 20% of web searches happen on Google Images.
  2. Monitor Search Console: Check for “Indexed, not submitted in sitemap” warnings.
  3. Keep it Lean: Exclude out-of-stock items if they won’t return soon.
  4. Use Lastmod: Ensure this feature is active so Google knows which pages are fresh.

Only 37% of SEOs find HTML sitemaps valuable today, but nearly 100% agree that XML sitemaps are a foundational requirement for modern e-commerce. By following this guide, you ensure your Magento 2 store is built on a solid technical SEO foundation.