Can't assign template to page

Hi all -

When I create a page, the ‘template’ option is greyed out and I can’t click the box. I created a new template in the sites > templates folder but it didn’t make a difference.

What am I doing wrong?

Many thanks!

The parent page setting does not allow creating pages with another blueprint. If you refer to a page on the first level, you have to change site.yml.

Right - thanks. So what is the best way to add a page that you don’t really need to edit in the panel and that has a unique layout?

You could hide it from the panel using the hide: true option in the page’s blueprint. As an alternative, you can make it read-only using permissions.

Thanks - perhaps this is off topic but if I simply just create a page in the panel, which generates its own folder in the content directory, how do I assign a template to it in the templates directory? I thought this was what the template box in the original question related to. For example, in the startup package, there is an ‘about.php’ file here, but if i duplicate it to ‘test.php’ to match my test page, it doesn’t seem to be assigned in any way, and no changes here affect the test page.

Hope that makes sense - thanks for your help!

The template is assigned through the filename. If a text file is called “about.txt”, Kirby will look for a template called “about.php”. If it exists, it is used to display the page, otherwise the default.php template is used.

The blueprint selected when creating a page in the Panel, on the other hand, determines the name of the text file. So if you select a template/blueprint called about, for example, your text file will be named “about.txt”.

Hmm it’s all what I expected but just not working. Here is an overview of my setup:

I have a page called ‘accreditations’ which I created in the panel, which made my content directory as shown:

Strangely, this didn’t create a blueprint - should it? I created it manually. I see in the ‘about.yml’ file
which came with the startup package, there is a ‘template:team’ line - what does this team relate to? I cannot find any team.php but there is a team.yml.

I tried adding an ‘accreditations.php’ file in the templates folder with the below code, but it doesn’t affect the accreditations page at all, so they’re not linked in any way.

<?php snippet('header') ?>
<header class="wrap">
  <h1><?= $page->title()->html() ?></h1>
  <div class="intro text">
    <?= $page->text()->kirbytext() ?>
  <hr />
<?php snippet('footer') ?>

No no no, I didn’t say it creates a blueprint, I said if you select a blueprint/template on page creation, the file gets the same filename as the blueprint.

There is a team.yml because this blueprint is used to create the team members which are subpages of the about page. There is no team.php template, though, because the team members are only shown on the about page that is rendered with the about.php template.

For example, if you take the Starterkit and create a subpage of blog, the article template/blueprint is preselected. The text file in the subpage folder will then have a filename of “article.txt”. Maybe it is a bit confusing that the select field is labeled template instead of blueprint. What you really select is the blueprint that determines the form fields that are shown in the Panel.

I found out what the issue was - when I create a page in the panel, the .txt file it creates in the content folder is by default called ‘default.txt’. not sure why it would do that but thats solved it at least!

As I explained above, that is because of the site.yml blueprint:

title: Site

pages: default

It only allows you to create first level pages with the default.yml blueprint (with the title “Page”). If you change that setting to

title: Site

pages: true

you will be able to select any blueprint and the files will be named accordingly.

1 Like

7 posts were split to a new topic: How to assign blueprints to pages