Forum

Thread tagged as: Question

Hiding a page that is just a URL from sitemap.

I have a sitemap on my site and on the main navigation on the links is to an external site.

I've used the perch tutorial to create the sitemap but for this external link I need to exclude the site URI from the link. How can I use the conditionals to do this? Sitemap

<perch:before><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
</perch:before>
<url>
    <loc><perch:if not-exists="https://connect.saloniq.co.uk/SalonIQ/OnlineBookings/Login/Index/COD001" >https://www.chapteronehairspa.co.uk</perch:if><perch:pages id="pagePath" /></loc>
</url>
<perch:after>
</urlset>
</perch:after>

Diagnostics

Perch: 2.8.34, PHP: 5.5.38, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_forms (1.8.3), perch_gallery (2.8.6)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_gallery' );
PERCH_LOGINPATH: /central
PERCH_PATH: /var/www/vhosts/chapteronehairspa.co.uk/httpdocs/central
PERCH_CORE: /var/www/vhosts/chapteronehairspa.co.uk/httpdocs/central/core
PERCH_RESFILEPATH: /var/www/vhosts/chapteronehairspa.co.uk/httpdocs/central/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
SCRIPT_NAME: /central/core/settings/diagnostics/index.php
REQUEST_URI: /central/core/settings/diagnostics/
DOCUMENT_ROOT: /var/www/vhosts/chapteronehairspa.co.uk/httpdocs
HTTP_HOST: www.chapteronehairspa.co.uk
Andrew Cetnarskyj

Andrew Cetnarskyj 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

for this external link I need to exclude the site URI from the link

What do you mean by that? What output are you getting and what do you need?

Simon Clay

Simon Clay 127 points

Hi Andrew, yes, you should be able to use something like this:

<perch:before><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
</perch:before>
<perch:if id="pagePath" match="neq" value="https://connect.saloniq.co.uk/SalonIQ/OnlineBookings/Login/Index/COD001" >https://www.chapteronehairspa.co.uk
<url>
<loc>
https://www.chapteronehairspa.co.uk<perch:pages id="pagePath" />
</loc>
</url>
</perch:if>
<perch:after>
</urlset>
</perch:after>

@drew, I was expecting to remove "https://www.chapteronehairspa.co.uk" from the outputted url if it is an external link.

Thanks

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If this is a Google sitemap then you don't want to include external links, they are not on your site which is what the Google sitemap is supposed to represent.

Simon Clay

Simon Clay 127 points

I think Rachel is right, you wouldn't normally list external pages on your sitemap.

But in answer to your question, to conditionally check for the external url you would use:

<perch:if id="pagePath" match="neq" value="https://connect.saloniq.co.uk/SalonIQ/OnlineBookings/Login/Index/COD001" >
  <!--Your code here-->
</perch:if>

Ok, this code lets me hide that link then from my sitemap, and save me building a second navigation group.

Thanks