Sitemap for search engines
Automatically create a sitemap for search engines.
For basic search engine optimization it's good to have a sitemap.xml file, which contains machine-readable information about all the pages and the structure of your site.
The syntax for such a
sitmap.xml file is fairly simple. You can find all about it on http://www.sitemaps.org/.
Because you probably don't want to generate that file by hand, you can create a snippet that indexes your entire site and generates a
sitemap.xml for you in a few steps:
Create a new snippet with the following content in
config.php, create these two new routes:
You can now to visit the sitemap of your Kirby site by browsing
http://yourdomain.com/sitemap.xml. The second route redirects to the first.
You can do that in your config. Here we call the option
The sitemap template will automatically try to create priorites for each page, by using the
->depth() attribute. The depth attribute is a simple number, which indicates how deep the page is nested. Main pages have a depth of 1, subpages of main pages have a depth of 2, etc.
home page will automatically get a priority of 1. You can easily change priorities or remove them entirely if you prefer.
To let your favorite search engines know about your brand new sitemap, please read the instructions on sitemap.org.
This is a very basic example. If you need something more complex, you can either use one of the plugins provided by the community, or extend it yourself, for example, by fine-tuning the options for pages you want to ignore (e.g. filter by template), or adding images.