Generate Sitemaps using Simple XML Sitemap in Drupal

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.

Getting Started

You can install this module using Composer as follows:

composer require drupal/simple_sitemap

The main module comes with 3 sub modules:

  1. Simple XML Sitemap – this is the main module which you should enable
  2. 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
  3. Simple XML Sitemap (Views) – this sub module allows you to add your Views pages to the sitemap
Figure 1

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

Module Configuration

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).

Simple XML Sitemap
sp

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).

Simple XML Sitemap - types
Figure 3

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.

Figure 4

Click on the Settings tab (/admin/config/search/simplesitemap/settings).

Figure 5

This Settings page has various miscellaneous settings that are self-explanatory.

Click on Inclusion (/admin/config/search/simplesitemap/entities).

Figure 6

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.

Figure 7
Figure 8

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.

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.

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.

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”.

Figure 11

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”.

Figure 12

Next, in the View modal popup, click on the checkbox as shown in Figure 13.

Figure 13

To view your final sitemap, at any point, you can go [YOUR SITE]/sitemap.xml

Summary

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.

2 thoughts on “Generate Sitemaps using Simple XML Sitemap in Drupal”

  1. Great one, but how about including information about the IndexNow capability of the simple_sitemap_engines submodule? It seems like this functionality is fundamental but there are no step-by-step guides yet.

Leave a Comment

You have to agree to the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.