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

CommentFileSizeAuthor
#4 simple_sitemap-n3426492-4.patch3.17 KBdamienmckenna

Comments

DamienMcKenna created an issue. See original summary.

gbyte’s picture

Title: Alias not used for sitemap URLs shown in sitemap index » Support path aliasing for sitmemap paths
Category: Bug report » Feature request

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

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

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.

damienmckenna’s picture

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.

damienmckenna’s picture

Assigned: damienmckenna » Unassigned
gbyte’s picture

Status: Needs review » Needs work

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 quite a 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.

walkingdexter’s picture

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 #3385550: Language negotiation breaks updating Drupal 9 to 10. So the change from #3369919: Unexpected language prefixes on sitemap index 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.

  • walkingdexter authored d4366c17 on 4.x
    Issue #3426492 by damienmckenna, gbyte, walkingdexter: Support path...
walkingdexter’s picture

Status: Needs work » Fixed
damienmckenna’s picture

Thank you!

Status: Fixed » Closed (fixed)

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