Skip to content
Manage the robots.txt from the Kirby config file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
vendor
.editorconfig
.gitignore
.php_cs.dist
README.md
composer.json
composer.lock
index.php

README.md

Kirby 3 Robots.txt

GitHub release License Kirby Version Kirby 3 Pluginkit

Manage the robots.txt from the Kirby config file.

Similar Plugin

Commerical Usage

This plugin is free but if you use it in a commercial project please consider to

Installation

  • unzip master.zip as folder site/plugins/kirby3-robots-txt or
  • git submodule add https://github.com/bnomei/kirby3-robots-txt.git site/plugins/kirby3-robots-txt or
  • composer require bnomei/kirby3-robots-txt

Setup

The plugin generates automatic defaults for the starterkit. You do not have to enter them in the config file. But if you would it would look like this.

TIP: If you are using the kirby3-xmlsitemap Plugin your sitemap will be automatically added to the robots.txt file. You can skip setting the bnomei.robots-txt.sitemap config value to sitemap.xml.

defaults for starterkit

<?php
return [
    'bnomei.robots-txt.content' => null, // string or callback
    'bnomei.robots-txt.sitemap' => null, // string or callback
    'bnomei.robots-txt.groups' => [ // array or callback
        '*' => [ // user-agent
            'disallow' => [
                '/kirby/',
                '/site/',
            ],
            'allow' => [
                '/media/',
            ]
        ]
    ]
];

using a plain string

<?php
return [
    'bnomei.robots-txt.content' => 'user-agent: *
disallow: /kirby/
disallow: /site/
allow: /media/',
];

using a callback

<?php
return [
    'bnomei.robots-txt.content' => function() {
        return site()->myRobotsTxtContentField()->value();
    },
];

sitemap and multiple user-agents

<?php
return [
    'bnomei.robots-txt.sitemap' => 'sitemap.xml',
    'bnomei.robots-txt.groups' => [
        '*' => [
            'disallow' => [
                '/',
            ],
        ],
        'googlebot-images' => [
            'allow' => [
                '/media/',
            ]
        ]
    ]
];

Disclaimer

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.

License

MIT

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.

You can’t perform that action at this time.