- Remember to exclude the sitemap from caching, search and the sitemap itself!
-
- and exclude only the pages you don`t wnt wto exclude
-
-
Save About2git/f700bb21888c8174e8a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Set correct header */ | |
header('Content-type: text/xml; charset="utf-8"'); | |
/* Echo the doctype */ | |
echo '<?xml version="1.0" encoding="utf-8"?>'; | |
/* Get ignored files from config file */ | |
$ignore = c::get('custom.sitemap.ignore', array()); | |
?> | |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | |
<?php foreach( $pages->index() as $page ): ?> | |
<?php /* Skip loop for ignored pages */ ?> | |
<?php if( in_array($page->uri(), $ignore) ) continue; ?> | |
<url> | |
<loc><?= html($page->url()) ?></loc> | |
<lastmod><?= $page->modified('c') ?></lastmod> | |
<priority><?= ($page->isHomePage()) ? 1 : number_format(0.5/$page->depth(), 1) ?></priority> | |
</url> | |
<?php endforeach ?> | |
</urlset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Don't cache the Sitemap*/ | |
c::set('cache.ignore', array('sitemap')); | |
/* Specify pages that will be excluded from the sitemap */ | |
c::set('custom.sitemap.ignore', array('sitemap', 'suche', 'error')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment