To configure the XML sitemap in Magento 2:

1. Go to Marketing > Seo & Search > Site Map

Magento 2 XML Sitemap Configuration

2. Choose an existing sitemap to edit or if you don't have any XML sitemap yet press the Add Sitemap button.

Magento 2 XML Sitemap Configuration

3. Then you have to set the name of the XML file of the sitemap in the Filename field, enter the Path where it will be located and press the Save & Generate button.

Magento 2 XML Sitemap Configuration, New Site Map

4. Once you have finished you'll see the list of Sitemaps. Press Generate a link to generate an XML Sitemap file. Note that a sitemap file is updated automatically by cron, you need to press "Generate" only if you want to update/generate Sitemap XML instantly.

Magento 2 XML Sitemap List

A standard Magento 2 XML Sitemap consists of links for products, categories, static pages, and product images.

Magento 2 XML Sitemap Auto-generation

In order to set Magento XML Sitemap to be generated automatically by Cron please go to Stores > Configuration > Catalog > XML Sitemap and find the Generation Settings section.

Magento 2 XML Sitemap Autogeneration

In Generation Settings, you have to Enable the autogeneration and set the Time and Frequency you want it to be generated at. We strongly recommend you to set it to be generated daily and at night time. In case something might go wrong and you want to be notified, set the Error Email Recipient, the Error Email Sender, and Error Email Template can have the default values.

Magento 2 XML Sitemap Auto-generation

Once you have finished don't forget to press the Save button.

Magento 2 XML Sitemap Configuration Save