Jump to:

10990 Posts in 2727 Topics by 1818 members

All other Modules

SilverStripe Forums » All other Modules » exclude page(s) from google sitemap programmatically?

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1259 Views
  • yurigoul
    Avatar
    Community Member
    202 Posts

    exclude page(s) from google sitemap programmatically? Link to this post

    Hi, is there a way to exclude a page-class from the sitemap.xml with a line of php code? I know this can be done by hand, but I want a certain page type to not show up at all, without user interference.

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: exclude page(s) from google sitemap programmatically? Link to this post

    Got it:

    Templates and pages who do not show up in search (even when search is not implemented on the site) do also not show up in the sitemap.xml. To make this the standard you could add the folowing code to your classes:

    static $defaults = array(
          "ShowInSearch" => 0
       );

    And you could add this to your getCMSFields()

    $fields->removeFieldFromTab("Root.Behaviour","ShowInSearch");

  • DNA
    Avatar
    Community Member
    24 Posts

    Re: exclude page(s) from google sitemap programmatically? Link to this post

    Or if you want the page to stay in search but be removed from sitemap then:

       protected function onBeforeWrite() {
          $this->Priority = '-1';
          parent::onBeforeWrite();
       }

    1259 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.