Omit the blog folder in sitemap


I omit the blog folder in the URL using routes:

And I have a sitemap with this code:


$ignore = array('error');

// Send the right header
header('Content-type: text/xml; charset="utf-8"');

// Echo the doctype
echo '<?xml version="1.0" encoding="utf-8"?>';


<urlset xmlns="">

    <?php foreach($pages->index()->visible()->not($ignore) as $p): ?>
            <loc><?php echo html($p->url()) ?></loc>
            <lastmod><?php echo $p->modified('c') ?></lastmod>
            <priority><?php echo ($p->isHomePage()) ? 1 : number_format(0.5/$p->depth(), 1) ?></priority>
    <?php endforeach ?>


I’d like to remove the blog folder in the sitemap URLs and I tried this approach:

It works fine, but I wonder if that’s the simplest way to do it or if it’s posible to omit that folder changing the sitemap code and without using models.

I use the Sitemap plugin, which offers much greater control.

A model is the easiest way to achieve that, because you can overwrite the native url() method and don’t have to change the code in other contexts of your site. Otherwise, you would need some sort of if statement in your sitemap code.

@jimbobrjames Could you please explain how that plugin solves the problems with the modified URL?

Ah… perhaps i misunderstood… i got that @11bits simply wanted to exclude some pages from the sitemap.

Yes, I know this plugin and it’s great, but I think it hasn’t this option.

No, and such a feature wouldn’t make much sense and only bloat the code.

Why don’t you want to use the page model? Do you want to remove the blog template?

Ok, I’ll continue using models.

Danke @texnixe

Un placer, @11bits (…)