Magento 2 Sitemap

Magento 2 Sitemap Tutorial on How to Configure a Sitemap, where is the path and how to use in multistore.

Sitemaps are basicaly the “Google Maps” of a site for the Google Search bot. Here we tell the bot were the pages are located, when they where last updated and how frequently we update each specific page.

Configuration #

  1. Login into the Admin Area.
  2. Hover over Marketing on the left side menu and under SEO & Search, click Site Map.
  3. In the Site Map Page click on Add Sitemap.
  4. On the newly loaded page New Site Map specify:
    • Filename - Here enter the sitemap file: For example: sitemap.xml
    • Path - you can use /sitemap/ or /
    • Store View
  5. Click on Save and Generate

You will have to wait a few minutes depending on the size of your Product Catalog and CMS Pages, once the sitempa is ready you will be redirected to the Site Map page and the Sitemaps gird will show the newly added sitemap.

Settings #

Path #

The Path of the sitemap is a combitation of 2 inputs, Filename + Path when you Configure the sitemap in the backend.<Path>/<Filename> So if you have:

  • Filename : sitemap.xml
  • Path - /sitemap/

the URL of this sitemap will be

Cron #

While there is no specific command to trigger only a sitemap generation you can still use the cron:run command and specify the default group, as this one contains the sitemap_generate job:

php bin/magento cron:run --group default 

This will return if successful:

Ran jobs by schedule.

It is very important to have your Cron setup and running as any updates done to the Product Catalog, Categories or CMS Pages will be added to the Sitemap.xml automatically upon system cron run.

MultiStore #

In a multi-store Magento setup you can speicfy a sitemap for each store view. Steps from Configure can be followed for each store view, making sure at point 3 the Store View is different and the Filename is someting like sitemap_us.xml for a US store view.

Extension #

The extension to generate a Google Sitemap is present out-of-box and available for Configuration.

Errors #

Issues can popup when getting the sitemap or when accessing it. Some of the common issues found are bellow with possible fixes.

Not Generating #

This can happen if the Path specified is not writable. To bypass this you can try and use the /media/ folder as that is writable by default.

404 #

If you are getting a 404 make sure you are using the Link to Google show in the Sitemaps Page grid. If the 404 still gets triggered make sure via FTP that the file is present in the filesystem and is not corrupted, you can download locally and open in your browser.

Need help with Magento 2 Sitemap ?