Configuring Magento 2 Sitemap

A Sitemap is a plain text XML file including link to all the pages on your website. The Search Engines will use Sitemap to properly crawl and index your website. In Magento 2, some things related to Sitemap are different from Magento 1 so in this post, we will bring you all tutorials related to Magento 2 Sitemap.

Enable a Sitemap

  • Login to Admin> Stores > Settings > Configuration > Catalog> XML Sitemap
  • Adjust settings for the options Category Options, Product Options, and CMS page Options as you want.
  • Set Generation Settings then adjust:
  • Enable: Yes
  • Start Time: Fill in a time after 00:00
  • Frequency: Choose Daily or Hourly depending on the products on your store
  • Error Email Recipient
  • Error email Sender
  • Error Email Template
  • Open Search Engine Submission> set Enable Submission to Robot.txt to Yes> Tap Save Config

Configure Sitemap

  1. Configure a sitemap for all stores

  • Create mkdir –p /data/web/magento2/sitemaps to store your sitemap
  • Admin Panel> Marketing> Seo & Search> Sitemap> Add a new sitemap
  • Insert all needed information like:
  • Filename: xml
  • Path: /
  • Store View: based on the quantity of your stores
  • Tap Save & Generate
  1. Configure a sitemap for each store

  • Create mkdir –p /data/web/magento2/sitemaps to store your sitemap ( You have to ensure that you have no sitemap in /data/web/public/sitemap.xml in order to avoid the incorrect sitemap
  • Admin Panel> Marketing> Seo & Search > Sitemap> Add new sitemap
  • Fill in the required information:
  • Filename: name your sitemap with convention: sitemap_&striecode.xml
  • Path: /sitemap/
  • Store View: choose an option you want
  • Tap Save & Generate

Add your sitemap location to your Robots.txt

  • After completing to request your sitemap.xml, you need add it to your Robots.txt:Sitemap: http://www.example.com/sitemap.xml

Configure nginx

  1. Configure nginx to use a sitemap for all stores

  • Login on your hypernode then open /data/web/nginx/server.sitemap
  • Create snippet below:
    location /sitemap.xml {   
        alias /data/web/magento2/sitemaps/sitemap.xml;
    }
  1. Configure nginx to use a sitemap for each store

  • Login on your hypernode then open /data/web/nginx/server.sitemap
  • Create snippet below:
    location /sitemap.xml {
    
       alias /data/web/magento2/sitemaps/sitemap_$storecode.xml;
    
    }

Read more: How to set up Sitemap in Magento 2?