How to configure Magento 2 XML sitemap?

An XML sitemap is a file that contains a list of URLs for your website. It helps search engines like Google to crawl your website and index its pages. Magento 2 has a built-in XML sitemap generator that can be configured from the admin panel. Here’s how to configure Magento 2 XML sitemap:

Step 1: Enable XML sitemap in Magento 2 To enable the XML sitemap in Magento 2, go to Stores > Configuration > Catalog > XML Sitemap. Set the “Enabled” option to “Yes”. You can also set the “Frequency” and “Priority” for the sitemap.

Step 2: Configure XML sitemap settings in Magento 2 In the same XML Sitemap configuration section, there are several settings you can configure. Here’s a brief overview of each setting:

  • Add Images into Sitemap: If you have images on your website, you can enable this option to include the images in the sitemap.
  • Categories Frequency: You can set how often the sitemap should be updated for categories.
  • Products Frequency: You can set how often the sitemap should be updated for products.
  • CMS Pages Frequency: You can set how often the sitemap should be updated for CMS pages.
  • Generate Sitemap Automatically: If you want Magento 2 to automatically generate the sitemap, set this option to “Yes”.
  • Sitemap File Limits: You can set the maximum number of URLs per sitemap file.
  • Sitemap Filename: You can set the filename for the sitemap file.
  • Sitemap Path: You can set the path for the sitemap file.

Step 3: Generate the XML sitemap in Magento 2 Once you have configured the XML sitemap settings, you can generate the sitemap. To generate the sitemap, go to Marketing > SEO & Search > Site Map. Click on “Add Sitemap” button, set the Filename and Path, and click on “Save & Generate” button. Magento 2 will generate the XML sitemap file and save it in the specified path.

Step 4: Submit the XML sitemap to search engines After generating the XML sitemap, you need to submit it to search engines like Google. You can do this by adding the sitemap URL to your Google Search Console account. To add the sitemap URL, go to Google Search Console, select your website, and click on “Sitemaps” under the “Index” section. Click on “Add/Test Sitemap” button, add the sitemap URL, and click on “Submit” button.

In conclusion, generating and submitting an XML sitemap is an essential step in optimizing your Magento 2 website for search engines. By following the above steps, you can configure and generate an XML sitemap in Magento 2 and submit it to search engines for better indexing and visibility.