Custom page plugin



Hi guys
I tried to create a custom page with a custom plugin

In docs there’s an example, but the plugin don’t found the template

In my plugin I added the template “example.html.twig” ander ther folder templates
Then, I subscribed the event “onGetPageTemplates” and I registered the template
Finally, I associated the new template at a page

But when I call ther route, Grav give me the error: Template “example.html.twig” is not defined.

There’s someone that can help me please?
Thank in advance


What you can do is…
Go to the absolute link of that page and see if it exists.
-> if it doesn’t, check for typo’s? If it does, check if it is in the right folder where your link goes to…

Good luck :slight_smile:


@luigimassa The docs you are referring to is only about defining and registering blueprints extending existing blueprints (‘default’) or creating custom blueprints (‘example’ in ‘/user/plugins/yourplugin/blueprints/example.yaml’). These blueprints are used by the Admin panel when creating pages.

This is only part of the story…

You also need to tell Grav on which path the custom template (‘example.html.twig’) can be found. This registration is done in PHP:

public function onTwigTemplatePaths()
    $this->grav['twig']->twig_paths[] = 'plugins://yourplugin/templates';

Hope this helps…


Thanks in advance.
It’s exactly the solution.

I’m newbie and documentation it’s not complete.

But with debug and forum I’m understanding the CMS

Thanks and regards