Postponed (maintainer needs more info)
Project:
Simple XML sitemap
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2020 at 11:30 UTC
Updated:
15 Aug 2025 at 02:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sohinicp commentedYeah ..face the same issue. if you check the view source, got the XML is coming properly but not in sitemal.xml page.
problem is coming from here 'Content-type' => 'application/xml; charset=utf-8',
But in the old version(8.x-3.1), this issue is not coming.
Comment #3
gbyteI don't think the two of you are encountering a bug. Something is probably breaking the XML structure. See e.g #3071738: XML not generated | Getting "error on line 2 at column 6: XML declaration allowed only at the start of the document".
In any case, please check the source of the page by pressing ctrl+u
Comment #4
angelamnr commentedI also ran into this issue. The reason the sitemap isn't working seems to be that the xml-stylesheet tag isn't picking up on the base_path of sites that use them. If my site is at https://www.example.com/foo, I would expect the xml-stylesheet to reference a relative path like /foo/sitemap.xsl. Instead, the xml-stylesheet is referencing the path /sitemap.xsl. The code that is causing this bug can be found here.
Is there a way to preserve proper CORS functionality while also keeping the sitemap's xml-stylesheet working for sites that need to use the base_path?
Comment #5
gbyte@angelamnr Are you saying that the following generates an invalid URL when the site is in a subdirectory?
This is the method that seemed to generate a consistent URL independent of the language subdomain it was run from. If it breaks like this we will have to try out something different.
Does anyone else experience this issue because of a subdirectory setup? If yes, I will gladly convert this issue back to a bug report and review patches.
Comment #6
angelamnr commented@gbyte Yes, that's correct.
Comment #7
dreg commentedWe also just ran into the same issue with a subdirectory.
Maybe it's possible to leverage the "Default base URL" in settings to override the XSL path?
Comment #8
dreg commentedJust tested this patch locally and it seemed to work, new to this module so not sure if it has implications outside of the XSL.
Comment #9
gbyteComment #10
gbyteComment #11
angelamnr commentedTested the patch and can also confirm that it works!
Comment #12
gbyteThis would be a workaround, but not one I can implement. What if someone does not use the base URL setting? Also we need a relative path for the XSL to avoid CORS issues. What happens if we trim that first slash, so instead of
href='/sitemap.xml'it'shref='sitemap.xml'? Shouldn't this then fetch the XSL file from the current directory?Comment #13
angelamnr commentedI tested that out and it works for me!
Here's a quick patch for that change.
Comment #14
angelamnr commentedComment #16
gbyte@angelamnr I realized this would not work for non-default variants, as their paths are non in the same directory as the XSL stylesheet is.
Therefore I propose the above solution.
@everyone Please test and reopen this issue if necessary.
Comment #18
keshavv commentedI am encountering the same issue on Version 4.1.9. In my local DDEV environment, everything works perfectly without any issues.
However, on the production server hosted on AWS, a blank page is displayed on
/sitemap.xml. If I uncheck the option Add styling and sorting to sitemaps in the module settings, then the XML file is displayed.Could someone please look into this?
Comment #19
keshavv commentedComment #20
kuldeepbarot commentedUpdated the patch mentioned here to make it compatible with version 4.2.2
Comment #21
gbyte@kuldeepbarot
Bug reports can only be opened against the dev version of the module - Can't change an existing release.
I just had a brief look at your patch; what happens when base URL is not set in the module settings?
Can anyone else confirm this to still be an issue?
Comment #22
luizsgpetri commented#18 worked for me.
Disabling the styling option fixed my issue.
Comment #23
aubjr_drupal commentedI just ran into the base_path() aspect of this issue.
If I rebuilt the queue and generated the sitemap from the Drupal UI at /admin/config/search/simplesitemap, it worked out of the box... but I was trying to get a recipe to install the modules, set up the sitemap configs, AND generate the desired sitemap with those configs in one shot by using the (experimental) Config Actions API and
$ php core/scripts/drupal recipe ../recipes/simple_sitemap.I got the recipe to mostly work, but I was getting a faulty sitemap with "http://:core/scripts" base URLs set for included image URLs and the XSL stylesheet href.
Setting the simple_sitemap.setting.base_url value fixed the image URLs, but the xml-stylesheet href tag still had the bad base URL value. And this patch was causing the problem. I removed that patch's base_path() and added a '/' in front of $xsl_url in the writePI() call, and the XSL stylesheet link was fixed.