Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Simple XML Sitemap 4.0.0 has been released!

Parent Feed: 

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. /** @var \Drupal\simple_sitemap\Manager\Generator $generator */

  4. $generator = \Drupal::service('simple_sitemap.generator');

  5. // Set some random settings.

  6. if ($generator->getSetting('cron_generate')) {

  7. $generator

  8. ->saveSetting('generate_duration', 20000)

  9. ->saveSetting('base_url', 'https://test');

  10. }

  11. // Set an entity type to be indexed.

  12. $generator

  13. ->entityManager()

  14. ->enableEntityType('node')

  15. ->setVariants(['default', 'test']) // All following operations will concern these variants.

  16. ->setBundleSettings('node', 'page', ['index' => TRUE, 'priority' => 0.5]);

  17. // Set a custom link to be indexed.

  18. $generator

  19. ->customLinkManager()

  20. ->remove() // Remove all custom links from all variants.

  21. ->setVariants(['test']) // All following operations will concern these variants.

  22. ->add('/some/view/page', ['priority' => 0.5]);

  23. // Generate the sitemap, but rebuild the queue first in case an old generation is in

  24. // progress.

  25. $generator

  26. ->rebuildQueue()

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

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

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web