Skip to content

Instantly share code, notes, and snippets.

@simonscheiber
Created August 15, 2012 22:07
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simonscheiber/3364125 to your computer and use it in GitHub Desktop.
Save simonscheiber/3364125 to your computer and use it in GitHub Desktop.
Kirby sitemap generator excluding invisible folders
<?php
$ignore = array('sitemap', '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="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach($pages->visible()->index() as $p): ?>
<?php if(in_array($p->uri(), $ignore)) continue ?>
<url>
<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>
</url>
<?php endforeach ?>
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment