Alias not used for sitemap URLs shown in sitemap index

Created on 7 March 2024, about 1 year ago

Problem/Motivation

If a path alias is added for a site variant it is not used when viewing the sitemap index.

Steps to reproduce

Create multiple Sitemap Variant definitions (admin/config/search/simplesitemap) that use the "Default hreflang" type.
Create a "sitemap index" sitemap variant.
Create a path alias for one of the sitemap variants.
Rebuild & generate the sitemaps.
Load the sitemap index.

Proposed resolution

Fix the bug that causes URLs to not use the path alias.

Remaining tasks

Fix the bug.
Add test coverage.

User interface changes

TBD

API changes

TBD

Data model changes

n/a

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

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

Comments & Activities

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

    Sitemap paths are not your regular paths. They are purposefully not normalized (you can't visit a localized version of the path) and there has never been a plan to support aliases. Since sitmemaps are supposed to be ingested by bots, their URLs don't matter to most.

    I haven't had a look, but how are you adding the aliases BTW?

    I don't plan on testing and implementing this, but feel free to try convincing me by creating a merge request.

    As with close to all the issues you've ever submitted, I wouldn't classify this as a bug from the get-go. XD

  • Assigned to DamienMcKenna
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    The alias was added through the normal path alias interface: /admin/config/search/path/add

    Non-normalized paths make SEO consultants cry ;-)

    While I understand that "sitemap.xml" is a standard path for scanner tools to load, the files loaded within that file, i.e. the site variant paths, have no such requirement. Drupal will load the sitemap variant with the aliased paths, but the index ignores this and uses the system path. While you consider this to be a feature request because you purposefully built it this way, I was unaware this was a purposeful choice so deemed it a bug as the expected behavior in Drupal is that all rendered paths use the alias if one is present.

    I'll work on a fix :p for this tomorrow.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    32 pass
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    How about this? It adds an option under the advanced settings that allows the sitemap URLs to be passed through the site aliases system. It defaults to off to avoid surprises for existing sites. Also the settings field warns against using it when using multiple languages, which triggered the original bug that lead to this change in the first place.

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA
  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany gbyte Berlin

    Having a setting that breaks one thing in order to allow something else is not an ideal situation. We turned off path processing in order to remove language prefixed paths. Instead of having two half-solutions, we should find a way to disable these language prefixes without breaking aliases. I'll be honest with you, it will have to be a quite clean solution to land. If you are still willing to look into it, thanks and good luck! Otherwise, this is quite niche so it's not at the top of my priority list.

  • πŸ‡·πŸ‡ΊRussia walkingdexter

    We turned off path processing in order to remove language prefixed paths. Instead of having two half-solutions, we should find a way to disable these language prefixes without breaking aliases.

    The original problem is already fixed in Drupal 10.3 πŸ› Language negotiation breaks updating Drupal 9 to 10 Needs work . So the change from πŸ› Unexpected language prefixes on sitemap index Fixed can be reverted, but the core version requirement should be increased to 10.3. I think we don't have to worry about it because 10.2 is no longer supported. Just tested all the changes and everything works fine, including path aliases.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Thank you!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024