Include custom kirbytag in a plugin

So I’m trying to do this…

    # My custom kirbytags
    'tags' => [

        # Overwrite the default (link:)
        'link' => require_once __DIR__ . '/inc/tags/link.php'


…and overwrite a bunch of default kirby tags with my custom versions.
I can’t seem to find the correct way to have the code for the tag in a separate file though.

The code for the tag itself works just fine when placed inside the plugin index.php but I want to split everything into chunks.

@texnixe can you point me in the right direction?

I can’t find anything in the docs.
Thank you

What is in your link.php?

There is an example in the repo, it’s a bit different because the file returns the complete tags array:

Ok so returning the entire array with all the tags seems to be working fine.

@manuelmoreale It also works the way you originally planned to do it, maybe you didn’t return anything from your file? That’s why I asked what you had in that file.



return [
    'html' => function($tag) {
        return '<a href="">Wikipedia</a>';

That’s odd because I had a code that was exactly like that.
I even tested with a stupid example like

return [
    'test' => function($tag) { return true }

And it wasn’t working. Maybe was just a typo somewhere :man_shrugging:
Anyway I think it could be useful to have an example in the docs.

I will think about this :wink: :white_check_mark:

1 Like