Forum

Thread tagged as: Problem, Error

Sitemap error after upgrading to Runway

I have successfully upgraded a Perch site to Runway but the previously working xml site map is giving an error. Having setup using the guide for Perch: https://docs.grabaperch.com/perch/content/functions/how-do-i-create-a-google-sitemap/

Error:

This page contains the following errors:
error on line 11 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.

Sitemap.xml:

    header('Content-type: application/xml');
    include('admin/runtime.php');
    perch_pages_navigation(array(
        'template'=>'sitemap.html',
        'from-path' => '/',
        'hide-extensions' => true,        
        'flat'=>true
      ));

Tried removing below but no joy:

    include('admin/runtime.php');

Any ideas, urgently need to fix this please?

Mark Watts

Mark Watts 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's on line 11?

Just an empty line, if I delete that so the last line is the close php tag I get this error:

This page contains the following errors:

error on line 10 at column 3: Extra content at the end of the document
Below is a rendering of the page up to the first error.

I'm running 3.0.2 Runway

Sitemap template code:

<perch:before><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
</perch:before>
<url>
    <loc>https://www.domainname.co.uk<perch:pages id="pagePath" /></loc>
</url>
<perch:after>
</urlset>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to look at line 11 of the output, not line 11 of the PHP source.

How do I do that? I've also tried enabling debug but nothing displays when .xml

If I change the file to .php extension and comment out the content type xml then the sitemap displays correctly no errors.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Did you have an .htaccess file that was enabling xml to be parsed as PHP? Is it still there?

I did have this:

AddHandler php-script .php .htm .html .xml
AddType application/x-httpd-php .php .htm .html .xml

I've added it back into the .htaccess file and now the page won't load:

This page isn’t working

yourdomainhere.co.uk is currently unable to handle this request.
HTTP ERROR 500
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should speak to your server admin - this isn't anything to do with Perch.

OK thanks for your help, just thought as it worked before upgrading perch to runway that it was that. I've used the following to get it working for now until I understand what's changed from running Perch.

in my .htaccess file:

RewriteRule ^sitemap\.xml$ sitemap.php [L]

in my sitemap.php file:

<?php
    header("Content-Type: text/xml;");
    include('admin/runtime.php');

    perch_pages_navigation(array(
        'template'=>'sitemap.html',
        'from-path' => '/',
        'hide-extensions' => true,        
        'flat'=>true,
      ));

?>