Simple XML Sitemap 4.0.0 has been released!

24 Nov 2021

After six months of work I'm delighted to tag the first stable release of the 4.x branch of the (Not-so-) Simple XML Sitemap module.

The project is in a really good place right now. At the moment of writing, drupal.org reports it being actively used on around 90k of Drupal 8/9 websites while having 0 open bug reports. This either means you people are lousy bug reporters, or we are doing a descent job at responding. :)

Module rewrite with developers/integrators in mind

4.x makes much greater use of Drupal's entity API dropping some of its very specific chaining API. Feel free to take a look at the roadmap ticket for specifics.

New UI

We now have a much nicer UI for creating, editing and sorting sitemaps as well as sitemap types.

Sitemap list UI

API usage

In a nutshell, sitemap variants are now sitemap entities. These are of a sitemap type (sitemap type entity) that is defined by URL generator plugins as well as sitemap generator plugins.

  1. // Create a new sitemap of the default_hreflang sitemap type.
  2. \Drupal\simple_sitemap\Entity\SimpleSitemap::create(['id' => 'test', 'type' => 'default_hreflang', 'label' => 'Test'])->save();
  3.  
  4. /** @var \Drupal\simple_sitemap\Manager\Generator $generator */
  5. $generator = \Drupal::service('simple_sitemap.generator');
  6.  
  7. // Set some random settings.
  8. if ($generator->getSetting('cron_generate')) {
  9. $generator
  10. ->saveSetting('generate_duration', 20000)
  11. ->saveSetting('base_url', 'https://test');
  12. }
  13.  
  14. // Set an entity type to be indexed.
  15. $generator
  16. ->entityManager()
  17. ->enableEntityType('node')
  18. ->setVariants(['default', 'test']) // All following operations will concern these variants.
  19. ->setBundleSettings('node', 'page', ['index' => TRUE, 'priority' => 0.5]);
  20.  
  21. // Set a custom link to be indexed.
  22. $generator
  23. ->customLinkManager()
  24. ->remove() // Remove all custom links from all variants.
  25. ->setVariants(['test']) // All following operations will concern these variants.
  26. ->add('/some/view/page', ['priority' => 0.5]);
  27.  
  28. // Generate the sitemap, but rebuild the queue first in case an old generation is in
  29. // progress.
  30. $generator
  31. ->rebuildQueue()
  32. ->generate();

See code documentation and readme for instruction on how to create URL generator and sitemap generator plugins and check out what other things can be done with the API. You are welcome to submit support requests in the matter as well as help improving the documentation.

Should you use this over 3.x?

Yes, read on though.

While the changes of this release are catered towards developers and site builders, I strongly encourage everyone to use the new version, as 3.x will be considered deprecated from now on. All new features and improvements will be coming to 4.x only. Do not panic however, I will be fixing bugs in 3.x for a while.

An update path is provided from previous module versions. Two reasons you might want to postpone upgrading is:

  • You depend on the old module's API and need some time to adjust it
  • You depend on 3rd party contributed simple_sitemap submodules that are yet to be made compatible with Simple XML Sitemap 4.x. In this case, please open up issues in the respective queues.

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

Thanks for everyone who has been involved in the development of this tool. Enjoy!

All info about the project

Comments

Congratulations on the release! I've always enjoyed using simple XML sitemap's flexible API - glad to see it's become even more powerful. The update went smoothly on all our deployments. Thanks for this awesome module!

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