Why you should be using Simple XML sitemap > 3.0

18 Nov 2018

This is a technical description of the 3.x branch of the module. For the newer 4.x branch, see this article.


Simple XML sitemap 3.0 has been released

The third major version of simple_sitemap has been seven months in the making. The module has been rewritten from the ground up and now features a more reliable generation process, a significantly more versatile API and many new functionalities.

Major new features

Ability to create any type of sitemap via plugins

The 8.x-3.x release allows not only to customize the URL generation through URL generator plugins as 2.x did, but also creating custom sitemap types that mix and match a sitemap generator along with several URL generators to create any type of sitemap.

This 3-plugin system coupled with the new concept of sitemap variants makes it possible to run several types of sitemaps on a single Drupal instance. Now e.g a Google news sitemap can coexist with your hreflang sitemap.

A sitemap variant can but does not need to be coupled to entity types/bundles. When creating a sitemap generator, one can define where the content source is located and what to do with it upon sitemap generation/deletion.

Ability to create sitemap variants of various sitemap types via the UI

In 3.x links form a specific entity bundle can be indexed in a specific sitemap variant with its own URL. This means, that apart from /sitemap.xml, there can be e.g

  • /products/sitemap.xml,
  • /files/sitemap.xml or
  • /news/sitemap.xml.

All of these can be completely different sitemap types linking to Drupal entities, external resources. or both. They could also be indexing other sitemaps. The name, label and weight of each variant can also be set in the UI.

Sitemap statusNo more out of memory/time errors

While the 2.x version of the Simple XML sitemap module has been appreciated for its simple generation process, that process sometimes failed because of timeouts and memory limits on huge sites in limited environments.

In order to address that, the generation process has now been streamlined to using a single queue regardless of whether batch generation is being used, or backend (cron/drush) processes. Setting a time limit on the cron generation and limiting the amount of links per sitemap allows for hundreds of thousands of entities/elements being indexed hopefully without memory errors.

If a problem occurs, the module resumes the generation process by picking up the last indexed element. Another thing the new version does better is making the old sitemap version accessible during its regeneration. This way there is never a time where bots cannot index stuff.

Other improvements

There are many more improvements compared to 2.x. You can see the list of changes on the module's release page.

Upgrade path

It was a challenge to do all of the above while still maintaining a smooth upgrade process, but it was worth it. The module upgrades fine from any of the 2.x versions.

To upgrade the module via composer, $ composer require 'drupal/simple_sitemap:^3.0' can be used. Afterwards, just visit /update.php, or run $ drush updb to update the module's storage.

Please bear in mind, that the module's API has undergone several changes, so if you are calling it in your code, the method calls may need some adjustment. Check out the code documentation and the readme file.

Should you upgrade?

A small portion of the 35k+ sites that are using this module have been rocking the 3.x development version and helping out by reporting issues. All of the bugs have been ironed out leaving a clean bug queue. I believe the 3.x branch to be stable and given its robustness, its enhancements and the smooth upgrade path, I encourage the rest of you to upgrade to the most recent release.

3.0 is great, but what is coming in 3.1?

Views support

Including view display URLs in the sitemap has been possible through adding these URLs as custom links in the UI (or via the API). View display variants however (most of the time views with arguments) are tedious to include as one would have to include every version of the URL. The integration of the simple_sitemap_views inside simple_sitemap 3.x will make this easily doable via the UI.

Thanks to @WalkingDexter for his tremendous work on this submodule!

XSL stylesheets

This will not change how bots interact with the sitemaps, it will however make the sitemaps readable and sortable for humans. This can be helpful when debugging the sitemap content or using the sitemap to visually present content to users.


I invite you to watch this space for a more in-depth technical tutorial on how to programmatically create sitemap types. Also feel free to leave a comment below!

All info about the project

Comments

How do we add a new variant for a multi-lingual website (having German and English)
I added this line to the new variants page,
german | de_hreflang | GermanMap
but I get this error
Line 2: The variant german is of a sitemap type de_hreflang that does not exist.

I need to have two separate sitemaps generated for the english and german languages, the pages are separated via /en and /de respectively

Any advice on how this could be rectified?

You do not need to add a variant in order to have a multilingual sitemap. You are thinking of an older standard where you needed to have different sitemaps for different language domains. That's not the case with this module, as it produses one sitemap that includes links to all language variants.

If you still want the older standard, you can either use xmlsitemap, or alter the sitmap generation process as described in this issue.

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang target> <em> <strong> <cite> <blockquote cite> <pre> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Get a quote in 24 hours

Wether a huge commerce system, or a small business website, we will quote the project within 24h of you pressing the following button: Get quote