We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Runway

Identify homepage in sitemap (and set right modified date and time format)

Hi, I wasn't really sure how to word my thread title!

Basically, I'm using the simple sitemap that is details in the docs here but i wanted to add a few extra bits of info.

So my template looks like this right now:

<url>
    <loc>http://salonsaver.co.uk<perch:pages id="pagePath" /></loc>
    <lastmod><perch:pages id="pageModified" /></lastmod>
</url>

That works just fine! However i want to add the <priority></priority> tag in there too... and that is where I'm stuck!

What I'd like to do is do something like "If pagePath is homepage then <priority>1.0</priority>, else <priority>0.2</priority>" but i can't for the life of me er out the syntax :^\

EDIT: Something else i just realised! The time / date format that is spat out by the template above is making google webmaster tools flag it up as "incorrect format". It appears to be looking for "2015-11-26T16:47:29+00:00" Any ideas on how i can do that too?

Daniel Owen

Daniel Owen 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use the format attribute to format the date and time.

To set the priority, how about using page attributes?

Hi Drew,

Ah ok, sounds like a plan! So i had a look in the docs for that and i can see how to set the correct format... like this:

perch_page_modified(array(
    'format' => '%Y-%m-%dT%H:%M:%S+00:00',
));

But no idea how on earth i output that to my page!

As you saw, i was doing it like this:

<lastmod><perch:pages id="pageModified" /></lastmod>

So how would i use the perch_page_modified array from above? Sorry if that sounds thick! I've been working on entirely different projects recently, not using perch (unfortunately!) so my brain isn't in Perch mode!

And... yeah that's a smart idea! I like it. Page attributes it is! Thank you :^)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Like this:

<lastmod><perch:pages id="pageModified" format="%Y-%m-%dT%H:%M:%S+00:00" /></lastmod>

Ah, simple as that! ~slaps forehead~ Cool, thanks a lot Drew :^)