
Magento 2 XML sitemap is one of many features in the Magento SEO guide that contribute to your website ranking. But that's not only that. The Magento sitemap is the main element linking your store with potential customers from search. If search robots can't discover your store, you won't get into Google index and the rest of the picture doesn't look good.
That's why it is important to understand the concept of Magento XML sitemap better. So, today you'll discover everything you need to know about Magento sitemap, how you can configure and automate it.
What is Magento XML Sitemap?
Magento XML sitemap, like any XML sitemap, is a file that contains links to all pages of a website. You submit this file to Google Search Console so that search bots can crawl and index your pages, which, correspondingly, are ranked in Google.
Products, categories and CMS pages are all included in the Magento XML sitemap. Besides, you can define how often robots should crawl these pages. The only downside is your pages are added to the crawling queue. So you don't know when Google will actually crawl your pages, unlike with the Google Indexing API.
But there is more to it. So we move to the next section to learn how you can configure the XML sitemap in Magento.
How to Configure Magento 2 XML Sitemap?
Magento sitemap configuration usually includes two steps if you're starting from scratch. First, you need to configure the basic settings like frequency and priority of indexing, and then actually create a sitemap file.
Let's start with the basics.
Basic settings
1. Go to Stores > Configuration > Catalog > XML Sitemap and go through the XML sitemap options.
![]()
2. Set Frequency and Priority in which you want categories to be indexed within Categories Options.
![]()
3. Complete Frequency and Priority settings for product options and decide whether you want to Add product Images into Sitemap.
![]()
4. Specify Frequency and Priority for indexing your CMS Pages.
![]()
5. Complete General XML sitemap Settings.
- Enable the sitemap generation.
- Set the Frequency and Start Time you want the XML sitemap to be updated at.
- Enter the Error Email Recipient who will receive a notification in case there are some errors while updating a sitemap.
- Select the Error Email Sender and Template to be used as the XML sitemap updating error notification.
![]()
6. Set the Site Map File Limits. to specify whether you'll have one sitemap file or several of them.
- Indicate the maximum number of URLs you want to be included in the sitemap in the Maximum No of URLs per File field.
- Enter the Maximum File Size to set the maximum size of the sitemap file in bytes.
![]()
7. Enable the Submissions to Robots.txt option to guide search crawlers on how to index your website better in the robots.txt file.
![]()
Sitemap generation
Now that you set up sitemap settings, you can create your XML sitemap file.
1. Navigate to Marketing > Seo & Search > Site Map and press the Add Sitemap button.
![]()
3. Set the name of the XML file in the Filename field, enter the Path where it should be located and press the Save & Generate button.
![]()
Once you finish you'll the generated sitemap in the list of sitemaps.
Note: a sitemap file is updated automatically by cron according to the generation settings you've set before.
Press the Generate button only if you want to update/generate the XML sitemap instantly.
Alternatively use the CLI command bin/magento magefan:sitemap:generate and add sitemap IDs bin/magento magefan:sitemap:generate --ids="2,4,6".
![]()
How to Generate a Separate XML Sitemap for Different Pages?
If you want better indexing management, and more detailed monitoring, you need to create separate XML sitemaps for different pages, like catalog or CMS pages. While it's not possible in default Magento, does it for you.
All you need to do is just add a sitemap the same way you just did, but choose what URLs to Include.
![]()
How to Add Custom Links to Sitemap?
By default, Magento includes products, categories and CMS pages in the XML sitemap. So, so either ignore all additional links or find a way to add them to your sitemap. And that way is Magefan XML Sitemap.
It allows you to add as many custom links as possible and set indexing frequency and priority for them.
Simply navigate to Stores > Configuration > Magefan Extensions > XML Sitemap > Additional Links and enable a corresponding option. Then add all the links you need and see them added to your sitemap.
![]()
How to Add Hreflang Tags to XML Sitemap?
If you manage a multi-language store on Magento, you probably use hreflang tags to notify Google about localized pages. But to help it discover those pages faster, you might as well add hreflang URLs to your sitemap. That's something our solution covers.
The best part? All you need to include hreflang URLs in your sitemap is to enable one option.
![]()
How to Automate Magento Sitemap Generation?
If you've followed this guide from the start, you might have noticed this. You've already set up the auto-generation of the sitemap.
Once you fill out the Generation Settings in the Stores > Configuration > Catalog > XML Sitemap section all you need is to submit the XML file to Google Search Console. Search robots will retrieve all the data from there.
![]()
How to Exclude Some Pages From XML Sitemap?
Although Magento allows you to handle the XML sitemap seamlessly, it doesn't offer an option to disable pages from the sitemap. And that might come in handy if you have some pages that you don't want in search results.
In that case, the Magento 2 XML Sitemap extension we've mentioned before will come in handy. It allows you to exclude any page from sitemap in Magento.
![]()
Magento 2 XML sitemap is a must for those who want to gain organic traffic from search engines. And if you're wondering if the default Magento feature is enough the answer is YES. You can definitely generate an XML sitemap using only the Magento feature.
However, don't forget that indexing is not the only thing you need to tackle to improve SEO. So you also need to have a look at canonical tags, hreflangs, meta tags templates, meta robots and other SEO-related features.