This is possible with the 8.x-3.x branch.

The easiest way to do it would be to implement your own sitemap generator plugin by extending Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\DefaultSitemapGenerator. You can then tweak the sitemap structure to your liking.

If you need URLs to also inject different data into the sitemap structure, implement a UrlGenerator plugin by extending the various URL generators, like Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator.

In order to replace the old sitemap and URL generator plugins with the new ones, either use the API method to alter the default or add a new sitemap type definition:

  1. \Drupal::service('simple_sitemap.generator')
  2. ->setSitemapTypeDefinition('default_hreflang', $definition);

... or use some hooks to alter the definition at runtime as this API example exemplifies:

  1. function hook_simple_sitemap_types_alter(array &$sitemap_types) {
  2.  
  3. // Remove the custom links generator from the default sitemap type definition.
  4. $key = array_search('custom', $sitemap_types['default_hreflang']['url_generators']);
  5. unset($sitemap_types['default_hreflang']['url_generators'][$key]);
  6.  
  7. // Define a new sitemap type to be generated with the default sitemap generator.
  8. // Make it use only the custom and arbitrary link generators.
  9. $sitemap_types['fight_club_sitemap_type'] = [
  10. 'label' => t('Fight Club Sitemap'),
  11. 'description' => t('The second rule of Fight Club is...'),
  12. 'sitemap_generator' => 'default',
  13. 'url_generators' => [
  14. 'custom',
  15. 'arbitrary',
  16. ],
  17. ];
  18. }

Hit me with any questions you might have. I will be publishing a blog post about all new features of 8.x-3.1 as soon as 3.1 arrives.

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.

Restricted HTML

  • Zulässige HTML-Tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <pre> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.

Angebot innerhalb von 24 Stunden

Ob ein großes kommerzielles System, oder eine kleine Business Seite, wir schicken ein Angebot ab innerhalb von 24 Stunden nachdem Sie diese Taste drücken: Angebot anfordern