Coder Social home page Coder Social logo

bnomei / kirby3-robots-txt Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 0.0 155 KB

Manage the robots.txt from the Kirby config file

Home Page: https://forum.getkirby.com/t/kirby3-robots-txt-manage-the-robots-txt-from-the-kirby-config-file/23587

License: MIT License

PHP 100.00%
kirby3 kirby3-cms kirby3-plugin robots-txt robots-exclusion-protocol

kirby3-robots-txt's Introduction

Kirby 3 Robots.txt

Release Downloads Build Status Coverage Status Maintainability Twitter

Manage the robots.txt from the Kirby config file.

Similar Robots.txt Plugins

Related SEO Plugins

Commercial Usage


Support open source!

This plugin is free but if you use it in a commercial project please consider to sponsor me or make a donation.
If my work helped you to make some cash it seems fair to me that I might get a little reward as well, right?

Be kind. Share a little. Thanks.

‐ Bruno
 
M O N E Y
Github sponsor Patreon Buy Me a Coffee Paypal dontation Hire me

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

Staging Server? Debug Mode = Disallow all

When you set the global Kirby debug config to true the plugin will disallow all indexing for all user-agents. This is especially useful on a staging server but you could consider xml-sitemap and rss-feed among other things as well.

⚠️⚠️⚠️ THIS MEANS IF YOU HAVE KIRBY'S DEBUG MODE ENABLED IN PRODUCTION ALL SEARCH ENGINES WILL BE BLOCKED FROM INDEXING YOUR SITE!

Adding Sitemap Link to Robots.txt

This plugin will add the sitemap link automatically to the robots.txt file for most available SEO plugins. You can skip setting the bnomei.robots-txt.sitemap config value to sitemap.xml in that case.

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.

defaults for starterkit

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

using a plain string

<?php
return [
    'bnomei.robots-txt.content' => 'user-agent: *
disallow: /kirby/
disallow: /site/
disallow: /cdn-cgi/
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.

kirby3-robots-txt's People

Contributors

bnomei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kirby3-robots-txt's Issues

[Docs] Is It Possible to Load Text from Site/Page Field?

The docs show how we can configure the robots.txt by using config settings, but is it possible to load the text directly from a field?

Asking because we often setup sites that are going to be 'tweaked' by SEO experts, who sometimes like to change the content on robots.txt - and I'd rather they did this in the Panel, and not have to access the config.php file directly...

Class 'Bnomei\Robotstxt' not found

I have installed you plugin on ma local env and everything looks OK.
But on my DEV server I get Class 'Bnomei\Robotstxt' not found error.

Can you help me please?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.