Base URL not properly added to the sitemap

Created on 2 July 2020, about 5 years ago
Updated 13 May 2025, 3 months ago

Problem

We are using websites in subfolders, with symlinks for path based site setup. Recently noticed that the sitemap URLs are broken and doesn't contain the "subfolder" in the URL anymore.

After checking the code we noticed that the url object for entities has the wrong URL as it shows http://example.com/contact instead of http://example.com/us/contact and due to this replaceBaseUrlWithCustom won't work properly.
This only behave incorrectly when we generate the sitemap with cron. I assume in this case the correct base path not set so links generated incorrectly.

Proposed resolution

Set base url on $url before replaceBaseUrlWithCustom would process it from the configuration of the module if its set.

🐛 Bug report
Status

Closed: cannot reproduce

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom fecka79

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany gbyte Berlin

    @sfuchsbe Not sure I'm following your latest comment. Is there any issue with the newest version of the module?

  • 🇩🇰Denmark ressa Copenhagen

    After having multiple problems with https://www.drupal.org/project/xmlsitemap -- not working correctly in a multilingual installation (it added the default language prefix, for example https://example.org/en/sitemap.xml) as well as having a default base URL of https://default, I am glad to report that both these things work perfectly in Simple XML sitemap:

    Automatic Base URL

    Simple XML sitemap automatically uses the URL of the Drupal installation (I did only try this with Drush) switching from for example https://mysite.ddev.site/ during development, to https://example.org/ on the server, without any configuration. Very impressive.

    Multilingual support

    Simple XML sitemap has multilingual support, again without any configuration -- it just works. Again, very impressive.

    Thanks for a fantastic module! If I were to make a single criticism, it would be that configuring it can be daunting ...

Production build 0.71.5 2024