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.
- Login into the Admin Area.
- Hover over
Marketingon the left side menu and under
SEO & Search, click
- In the
Site MapPage click on
- On the newly loaded page
New Site Mapspecify:
- Filename - Here enter the sitemap file: For example: sitemap.xml
- Path - you can use
- Store View
- 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.
The Path of the sitemap is a combitation of 2 inputs,
Path when you Configure the sitemap in the backend.
So if you have:
the URL of this sitemap will be https://www.example.com/sitemap/sitemap.xml.
While there is no specific command to trigger only a sitemap generation you can still use the
cron:run command and specify
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.
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.
The extension to generate a Google Sitemap is present out-of-box and available for Configuration.
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.
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.