This feature is available with all block themes.
Theme developers can opt-in to add it to classic themes.
Level: Beginner, no code
Estimated reading time: 5 minutes
Templates are optional designs for pages and posts. They let you select different designs for different content. The default WordPress theme Twenty Twenty includes two templates, the Cover Template, and the Full Width Template.
While traditional templates are created with code by developers, a template in full site editing can be created by anyone, using the block editor and the same type of blocks that you use in your content.
Limitations with templates today
Themes often include a template to give you the option of using different headers or sidebars. Sometimes you can make changes to templates with options in the Customizer.
Templates have been available in WordPress for a long time, but there have been very few improvements to how you can use them.
Let’s look at some of the problems:
Only theme developers can create traditional templates
If you have a theme with a sidebar but you would like to remove the sidebar from a page, you would need to know how to code to hide it or create a new template without a sidebar.
You can not preview templates before you select them
You choose templates by opening a post or page in the block editor and selecting a template from the Page Attributes Template section. All you have to go by is the name:
You can not see what the template looks like when adding and editing content
When you have selected a template, you can only see what the page will look like by viewing the website on the front. There is no editing of the content in place in the template.
Improvements to templates with full site editing and WordPress 5.8
A new template editing system is part of full site editing and improvements have been made to address these problems in WordPress 5.8.
A new type of template that is editable
Themes can include two types of templates:
- The current type of page template that can not be edited. Existing templates will not change. Post and pages that use these templates will not change or break.
- A full site editing block template that can be edited. You create this template using blocks.
Two ways to edit templates within WordPress
There are two ways to edit templates without code. Both allow you to edit full pages.
Just like today, you decide if you want to use a custom template or not. It is completely optional.
- The template editor. A part of the block editor.
- The site editor. An advanced template editor only available with the Gutenberg plugin active.
The site editor is a new interface where all templates, posts and pages can be selected, previewed and edited. When viewing a page in the site editor, you always see the full page.
This new interface can feel overwhelming, and because of that, the more basic template editing mode was created.
The template editor
I will cover details of the template editing mode in the next lesson.
The template editing mode is part of the block editor. You access it from a new section in the document sidebar called Template:
The template editing mode is very similar to the block editor, the difference is that you are viewing the full page.
Here is what this page looks like in the template editing mode using Gutenberg 10.7.1:
Create your own templates
Users are no longer limited to the templates that the theme developer adds. You can create new templates with blocks. Clicking the “New” link in the template section will create a new template for your current page.
Choose to see the full page template when writing your content
You can edit content in the block editor like you are used to. Or you can click the “Edit” link in the template section to open the template editing mode.
Coming soon –Preview templates before assigning them
This feature is still being developed and tested. The goal is that you will be able to select a template from a preview and not only a name.
Here is one of the proposed designs for the template preview: