There are already four other robots plugins:
…so why make another one?
I really wanted to open up the possibilities to add robots.txt
content anywhere you want, in a snippet, in a site field or in a page field.
Plenty of options, in this tiny plugin:
Robots by snippet
In config.php
, add something like this:
c::set('plugin.robots.writer.type', 'snippet');
c::set('plugin.robots.writer.snippet.name', 'robots');
Add a snippet in the snippet
folder or register one in a plugin like this:
$kirby->set('snippet', 'robots', __DIR__ . '/snippets/robots.php');
https://getkirby.com/docs/developer-guide/plugins/registry
Robots by site
In config.php
, add something like this:
c::set('plugin.robots.writer.type', 'site');
c::set('plugin.robots.writer.field.name', 'robots');
In site.txt
add something like this:
fields:
robots:
title: Robots
type: textarea
Robots by page
In config.php
, add something like this:
c::set('plugin.robots.writer.type', 'page');
c::set('plugin.robots.writer.field.name', 'robots');
c::set('plugin.robots.writer.page.uri', 'my/custom/page');
In my_template.txt
add something like this:
fields:
robots:
title: Robots
type: textarea
Enjoy!