Version 0.1
A sitemap xml plugin without boundaries.
Add this to the snippet sitemap-query.php
:
sitemapQuery::add('https://example.com/contact');
sitemapQuery::add(array(
'loc' => 'https://example.com/about',
'lastmod' => '2004-11-23',
'priority' => '0.3',
'changefreq' => 'weekly'
));
Use one of the alternatives below.
If you are using the Kirby CLI you can install this plugin by running the following commands in your shell:
$ cd path/to/kirby
$ kirby plugin:install jenstornell/kirby-sitemap-query
- Clone or download this repository.
- Unzip the archive if needed and rename the folder to
kirby-sitemap-query
.
Make sure that the plugin folder structure looks like this:
site/plugins/kirby-sitemap-query/
If you know your way around Git, you can download this plugin as a submodule:
$ cd path/to/kirby
$ git submodule add https://github.com/jenstornell/kirby-sitemap-query site/plugins/kirby-sitemap-query
Add a snippet to site/snippets/sitemap-query.php
if that is your folder structure.
If you send a string, it will be interpreted as url.
sitemapQuery::add('https://example.com');
sitemapQuery::add('https://example.com/about');
sitemapQuery::add('https://example.com/contact');
If you send an array, you can add the arguments you want.
sitemapQuery::add(array(
'loc' => 'https://example.com/about',
'lastmod' => '2004-11-23',
'priority' => '0.3',
'changefreq' => 'weekly'
));
Read more about the arguments here: https://www.sitemaps.org/sv/protocol.html
If you don't add a snippet it will fallback to the snippet below:
<?php
foreach( site()->index() as $page ) {
$url['priority'] = ( $page->isHomePage() ) ? 1 : '0.5';
sitemapQuery::add(array(
'loc' => $page->url(),
'lastmod' => $page->modified('Y-m-d'),
'priority' => $url['priority'],
));
}
The result will look like this on your domain http://example.com/sitemap.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://localhost/kirby/2.4.0/projects</loc>
<lastmod>2016-11-15</lastmod>
<priority>0.5</priority>
</url>
<url>
<loc>http://localhost/kirby/2.4.0/projects/project-a</loc>
<lastmod>2016-11-04</lastmod>
<priority>0.5</priority>
</url>
</urlset>
The following options can be set in your /site/config/config.php
file:
c::set('plugin.sitemap.query.url', 'sitemap.xml');
c::set('plugin.sitemap.snippet.query', 'sitemap-query');
c::set('plugin.sitemap.snippet.template', 'sitemap-template');
Change the url sitemap.xml
if you want.
The snippet query file is snippet-query.php
but you can change it if you want.
The snippet template file is snippet-template.php
but you can change it if you want.
0.1
- Initial release
- Kirby 2.3+
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.