The Simple XML Sitemap automatically generates a XML sitemap for your Drupal website whilst adhering to Google’s latest recommendations and guidelines. There are various customizations that this module allows, all of which are listed in more detail on the module’s page.
This tutorial will show you how to install this module and configure it on content types, links, menus and view pages.
You can install this module using Composer as follows:
composer require drupal/simple_sitemap
The main module comes with 3 sub modules:
- Simple XML Sitemap – this is the main module which you should enable
- Simple XML Sitemap (Search Engines) – this sub module can be configured to use cron to automatically submit your site to search engines such as Google and Bing
- Simple XML Sitemap (Views) – this sub module allows you to add your Views pages to the sitemap
For this tutorial, we will enable Simple XML Sitemap (main module) and also Simple XML Sitemap (Views). You can do this via the admin UI or with Drush as follows:
drush en simple_sitemap simple_sitemap_views -y
Once the module is enabled for the first time, it will create one sitemap for you but it does not include any Drupal entities by default.
We will walk through each of the module’s configuration pages.
Go to Configuration -> “Simple XML Sitemap” (/admin/config/search/simplesitemap).
This page lists the sitemaps already created. You can create more than one sitemap if needed. The “Rebuild queue & generate” button can be used to quickly rebuild the sitemap if you made any configuration changes.
Click on the Types tab (/admin/config/search/simplesitemap/types).
The “Types” page lists all the sitemap types that you can create. You should click on the “edit” button here to include the Views URL generator so that the sitemap can include Views pages as shown in Figure 4.
Click on the Settings tab (/admin/config/search/simplesitemap/settings).
This Settings page has various miscellaneous settings that are self-explanatory.
Click on Inclusion (/admin/config/search/simplesitemap/entities).
The Inclusion page will give you a quick summary glance of which entities are enabled.
Content Type in Sitemap
Go to Configuration -> “Simple XML Sitemap” -> Inclusion (/admin/config/search/simplesitemap/entities).
The Inclusion tab is where you specify which Drupal entity you want to include in the sitemap. Let’s enable the Content Entity. Click on Configure as shown in Figure 7.
Then click on the content type you want to enable in the left column and select the radio button as shown in Figure 8. Then click on “Save configuration”.
Then go to /admin/config/search/simplesitemap (see Figure 2) and click on “Rebuild queue & generate”.
The sitemap will be rebuilt and all content of type “Articles” will now be included.
Custom Link in Sitemap
If you need to include custom links, you can do that manually by going to Configuration -> “Simple XML Sitemap” -> Inclusion -> “Custom links” (/admin/config/search/simplesitemap/custom).
Then manually add the links as shown in Figure 9.
In Figure 9, we have added “/my-custom-link 1.0 daily”.
/my-custom-link – this is the link to any custom internal page
1.0 – this is the link priority
daily – this is the link change frequency
Custom Drupal Menu in Sitemap
Any of your Drupal menus can be added to the sitemap by going to Configuration -> “Simple XML Sitemap” -> Inclusion (/admin/config/search/simplesitemap/entities).
Then click on “Configure” as shown in Figure 10.
Then click on the desired menu from the left column and select the radio button as shown in Figure 11. Click on “Save configuration”.
Custom Views Page in Sitemap
First you need to enable the Views URL generator as described by Figure 4.
Then, go to: /admin/structure/views and edit the View that you want to include.
In the View edit screen click on “Exclude from all sitemap”.
Next, in the View modal popup, click on the checkbox as shown in Figure 13.
To view your final sitemap, at any point, you can go [YOUR SITE]/sitemap.xml
The Simple XML Sitemap module is a neat little module that can automatically generate a XML sitemap for your Drupal site. You can include/exclude and customize entities into your sitemap such as content types, custom menus and View pages. If you deeply care about improving the SEO of your Drupal website, this module should definitely be used.