Jump to content

How to prevent "test" pages from being included in WireSitemapXML sitemap.xml


Jonathan Lahijani
 Share

Recommended Posts

I oftentimes create a checkbox field called 'test' and assign it to certain templates.  I check the box if the page is a test page.  These pages may exist on the live site and I don't want to hide or unpublish them, but at the same time, I don't want them to appear in the XML Sitemap.  (not part of this tutorial, but I also noindex,nofollow those pages using a meta tag in the head so search engines don't index them)

In that case, you can remove them from the WireSitemapXML like this in /site/ready.php:

$wire->addHookAfter('WireSitemapXML::allowPage', function(HookEvent $event) {
  $page = $event->arguments('page');
  if($page->hasField('test') && $page->test) $event->return = false;
});

 

  • Like 14
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...