The sitemap.xml file is missing the tags.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><lastmod>2017-09-28T12:34Z</lastmod></sitemap>
<sitemap><lastmod>2017-09-28T12:34Z</lastmod></sitemap>
</sitemapindex>

I also got the following warning

XMLWriter::writeElement() expects parameter 2 to be string, object given XmlSitemapWriter.php:210

I was able to fix this by change line 55 in src/XmlSitemapIndexWriter.php from

        'loc' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $url_options),

to

        'loc' => Url::fromRoute('xmlsitemap.sitemap_xml', [], $url_options)->toString(),

Url::fromRoute returns an object while we need a string there.

CommentFileSizeAuthor
#2 sitemap_xml_index-2912413-2.patch674 bytesrenatog
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drone.ah created an issue. See original summary.

renatog’s picture

Hi @drone.ah, how are you?

Make sense.

In attachment the patch with the fix.

Regards.

  • RenatoG committed cd0bf3d on 8.x-1.x
    Issue #2912413 by RenatoG, drone.ah: sitemap.xml index missing <loc>
    
renatog’s picture

Component: xmlsitemap.module » Code
Status: Active » Fixed

Fixed.

Committed to the dev branch.

We are going to generate a new release soon.

Thank you very much @drone.ah for your contribution.

Regards.

Status: Fixed » Closed (fixed)

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