Forum

Thread tagged as: Problem, Question

Page Attributes in Sitemap Template

Hi there,

I'm having difficultly extending the site map guide here: https://solutions.grabaperch.com/html-and-css/how-do-i-create-a-google-sitemap to have more options for my client.

I cannot get the page attributes I've set to appear. Here is my default.html template:

<perch:template path="pages/attributes/seo.html" />

<perch:pages divider-before="Sitemap" id="changefreq" label="Change Frequency" type="select" options="always,hourly,daily,weekly,monthly,yearly,never" help="How frequently the page is likely to change. The value 'always' should be used to describe documents that change each time they are accessed. The value 'never' should be used to describe archived URLs." default="monthly"/>

<perch:pages id="priority" label="Priority" type="select" options="0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0" help="Search engines may use this information when selecting between URLs on the same site, so you can use this tag to increase the likelihood that your most important pages are present in a search index." default="0.5" />

and the sitemap.html template:

<perch:before><?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
</perch:before>

<url>
    <loc>https://bridgehouselangworth.co.uk<perch:pages id="pagePath" /></loc>
    <lastmod><perch:pages id="pageModified" /></lastmod>
    <perch:if exists="changefreq"><changefreq><perch:pages id="changefreq" /></changefreq></perch:if>
    <perch:if exists="priority"><priority><perch:pages id="priority" /></priority></perch:if>
</url>

<perch:after>
    </urlset>
</perch:after>

Cheers!

James Wigger

James Wigger 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you displaying the site map?

Hi Drew,

It's output using perch_pages_navigation:

<?php
    header('Content-type: application/xml');
    include('admin/runtime.php');
    perch_pages_navigation(array(
        'template'=>'sitemap.html',
        'flat'=>true,
    'use-attributes' => true
    ));
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Does adding <perch:showall /> to the template reveal anything?

{"description":{"raw":"","processed":""},"keywords":{"raw":"","processed":""},"changefreq":"always",{...}

It seems like they are being added to the database at least.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not quite sure what you're telling me there - where's that JSON from?