Add documentation on adding arbitrary links to the sitemap index

Created on 14 March 2023, over 1 year ago
Updated 19 July 2024, 4 months ago

Problem/Motivation

I have a single-page application under the same domain as my Drupal site. That app is providing a sitemap.xml file that I need to include in the Drupal sitemap index.

Proposed resolution

Add an alter hook to the API to allow adding external sitemap information to the SitemapIndexUrlGenerator methods.

API changes

Add hook_simple_sitemap_external_sitemaps_alter() to the API.

πŸ“Œ Task
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @weekbeforenext
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    You should already be able to do that:

    Clean way:
    Implement a new Extermal sitemap URL generator plugin collecting links to those sitemaps and add it to your Sitemap Index sitemap type under /config/search/simplesitemap/types/index.

    Less clean way:
    Add the Arbitrary URL generator to your Sitemap Index sitemap type and implement the hook hook_simple_sitemap_arbitrary_links_alter().

    Check out the documentation and let me know if that helps or if you need other pointers.

  • πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC

    I couldn't figure out why the index sitemap wasn't showing up when I put a breakpoint in a hook_simple_sitemap_arbitrary_links_alter() implementation. It was as simple as updating the "Sitemap Index" type to include "Arbitrary URL generator".

    Thanks so much for your quick response. I had fun adding this functionality and learning more about how this module works. I'll take that as a win. :)

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    I couldn't figure out why the index sitemap wasn't showing up when I put a breakpoint in a hook_simple_sitemap_arbitrary_links_alter() implementation. It was as simple as updating the "Sitemap Index" type to include "Arbitrary URL generator".

    I don't blame you - this module has become very flexible and even though I've been trying, not everything in the UI is intuitive. E.g. in order for the sitemap index to index all other sitemaps, it should be generated last - this can be achieved by dragging it underneath all other stiemaps in the UI.

    Maybe we need more comprehensive documentation for cases like yours.

    Thanks so much for your quick response. I had fun adding this functionality and learning more about how this module works. I'll take that as a win. :)

    Happy to hear that!

    • gbyte β†’ committed 4ea3edc3 on 4.x
      Issue #3347996 by weekbeforenext, gbyte: Add documentation on adding...
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin
Production build 0.71.5 2024