Setting up a content type to be optimized for search engines using sitemap.xml protocol in Drupal 10

We already made for some search engine optimization on our brand new Drupal 10 website greenlight.ru. During the previous stages of the project we made sure our site has crisp semantic structure, non-default theme and web design compliant with modern HTML standards. Now we start taking more straightforward steps to ensure our web site is being parsed and ranged by miscelaneous search engines in a more efficient way.

The Sitemap XML protocol is a way for a webmaster to help search engines more quickly and efficiently index websites. It is described in full here: https://www.sitemaps.org/protocol.html

We will use the Drupal contrib module titled "Simple XML sitemap" in order to:

  • automate creation of sitemap via different settings,
  • create a sitemap index of other sitemaps,
  • periodically submit changed content to search engines
  • submit to IndexNow service on content changes
  • reflect Views and views arguments
  • provide a nice readable format to human visitors via XSL stylesheets
  • test the script included for performance

Let's go: https://www.drupal.org/project/simple_sitemap

Run this command in your terminal in the main directory of your Drupal website:

composer require drupal/simple_sitemap

Let's enable the module in the Drupal Admin dashboard:

Add /admin/modules to your site's domain name and hit enter or go to through the navigation menu: Administration / Extend and then enable the Simple XML sitemap module by checking all of the 3 modules in the "SEO" section:

  • Simple XML Sitemap
  • Simple XML Sitemap (Search engines)
  • Simple XML Sitemap (Views)

Then click "Install" buttom below the page.

You will see the following messages:

Warning message

  • In order to generate a verification key for the IndexNow service and choose which sitemaps are to be submitted to search engines, visit this configuration page.
  • In order to use the Simple XML Sitemap Views module, the Views URL generator must be added to a sitemap type.

Status message

  • 3 modules have been enabled: Simple XML Sitemap (Search engines), Simple XML Sitemap (Views), Simple XML Sitemap. Configure related permissions.
  • One translation file imported. 56 translations were added, 39 translations were updated and 0 translations were removed.
  • No configuration objects have been updated.

===

After installing the set of modules some new SEO-related features and functions will become available to you.

The new section has been added to your Drupal website Admin / Configuration (/admin/config): "Search and metadata".

We can set up much of that later. For the thing to start really working we need to create rules for pages of the website to be be added to sitemap.xml being updated. Let's say we need all story and page types of content to be in automatically.

Let's go and edit each content type we need to set up: Admin / Structure / Types / Article / edit

Please see the picture above for the detailed settins. 

After setting up the sitemap.xml for the main content types of our website let's move on. We want to start using a free SEO sevice of "The IndexNow" sponsored by Yandex and Microsoft corporations as they both encorage webmasters to push fresh sitemap.xml from websites to their branded search engines. We will use this opportunity to become more competitive.

We need to generate unique verification key for the website to use the free service IndexNow by going to this URI on our website: /admin/config/search/simplesitemap/engines/settings and then clicking the button Generate Key on that page.

After the key was generated you will see the Warning message with a line of code you will need to add to the Drupal settings.php file. I added right after Drupal's hash salty setting:

$settings['simple_sitemap_engines.index_now.key'] = 'yourcodehere';

In "Sitemap submission settings" choose to use "Default" sitemap for Google.

Then click "Save Settings" button below.

Now we can check if our website became more optimized for general search engine indexing by going to https://greenlight.ru/sitemap.xml 

We will continue to explain SEO for Drupal websites in the next articles... this was just the beginning. 

Tags