Page templates

Contents

Create page templates to reuse a page across different content items.

Reusable pages

Previously, we mentioned that you’d get to know about the Templates folder a bit later. The time has arrived.

With the current approach, you would have to configure a new page for every country in the list. A slightly more efficient approach is to use page templates. Page templates can be mapped to a specific content type i.e. "Country" - and all content items of type "Country" will be rendered by it.

Let’s take advantage over the fact that we have already created a page for a city.

  1. Select, and Edit the City with the page

  2. Select the page component, and from the context menu click Save as Template

  3. Give your Template a suitable name i.e. Country template

  4. Choose Country in the Supports dropdown.

    Here is a video demonstrating the process.

Creating a page template from a page

Now, when you select city content elements in the Content grid you’ll notice that each of them is rendered by the page template.

From scratch

Just like any other piece of content, a page template can also be created from scratch.

  1. Select the Templates content item and then click new

    List of content types under the root site content, with the Templates highlighted
  2. Select the Page template content type

    Modal showing the page template content type
  3. Select Country content type from the "Supports" dropdown.

    List of available content types under the support filter, with the Country content type highlighted
  4. In the panel on the right select the Hello Regions! page

    List of available pages, with the Hello Regions! page highlighted
  5. Right click on Drop here region in the added page, then Insert and Part and select the City list part.

    List of available parts to be added withing a region, with the Country part highlighted
  6. Then finally give this page template a name, such as "New Country Template" and save it.

Try clicking other countries to verify that the template actually works as intended.

Automatic, fixed or customized

The country item you manually edited still uses the custom page you created - you can make it use the page template as well.

  1. Edit the initial country, open the page editor and select the page.

  2. From the right hand component view, change the Template setting from Custom to Automatic

For every single content item, you can use Automatic (default), select a specific template or customize the page, "unlinking" it from its page template.
You now have two page templates, both of which support "Country" content type. In this case "Automatic" mode will pick up the newest template, which is "New Country Template". If you want to use the old template, you need to select it explicitly.

Summary

You’ve just learned about page templates, which is a way to reuse a page across specific content types within your site. This is a powerful feature of the CMS, as it enables editors to manage and publish page templates, just like any other content.

If you want to control the rendering of certain pages without using page templates, check out controller mappings.

Next up, let’s see how to add and serve static assets, using the built-in asset service.


Contents

Contents

AI-powered search

Juke AI