Using page templates in MVC

Page templates allow you to gain greater control over the layout of pages, without the need to ask a developer to modify the code of your MVC project. When creating a page, you can choose from two types of page templates:

  • Default templates are defined in the code of an MVC project by developers. They only specify the layout of a page, waiting for the content to be added.
  • Custom templates are always based on a default template. On top of the layout defined in the original default template, custom templates also incorporate a snapshot of page builder content (such as widgets and sections). This page builder content serves as a starting point for new pages and can then be adjusted for each page (there is no permanent “link” between the content of pages using the same template). Structured page data edited on the Content tab of a page is not saved within custom templates. To create custom templates, save existing pages as templates.

Creating pages based on page templates

To create a page based on a template, follow the instructions on the Creating new pages in MVC page.

The page template selection dialog may only be available for certain types of pages (or rely on other factors, such as the page culture and location within the content tree). The available template options depend on your site’s implementation. If you are a developer and wish to learn how to create default templates, see Developing page templates in MVC.

Configuring page templates

You can configure a page template to further control the overall appearance of the page.

  1. Open the Pages application.
  2. Open a page based on a template and switch to the  Page tab.
  3. Click the orange configure button () located in the bottom-left corner of the page window.
    Clicking the configure button
  4. Configure any available properties in the dialog.
    Configuring a page template
  5. Click Apply.

The configured properties now apply to the template for the given page. Any other pages that use the same template have their own separate property configuration. Depending on the available properties, the changes are reflected in the page’s appearance or behavior on the website.

Changing templates of existing pages

You can change the page template of an existing page, provided there is more than one page template available for the given page.

Content not preserved when changing templates

When changing the template of an existing page, all page content (i.e. widgets and sections with their data and properties) is lost. You should therefore change templates only in the early stages of page development. 

  1. Open the Pages application.
  2. Select a page based on a template and switch to the Page tab.
  3. Click the orange change template button () located in the bottom-left corner of the page preview window.
    Change template button.
  4. Select one of the available default or custom templates.
    Changing page template of an existing page
  5. Click Apply.

Saving pages as custom page templates

If you want to reuse page builder content, such as the layout of sections or content of widgets, you can save template-based pages as custom templates. Structured page data (edited on the Content tab of a page) is NOT saved within custom templates.

  1. In the content tree in the Pages application, navigate to a location where page templates are enabled.
  2. Create a new page based on an existing default template.
  3. Edit the page to add some content. You need to Save the edited page before you can proceed to the next step.
  4. Click the expand () button in the upper-right corner to show more actions and select Save as template. A dialog box opens.
  5. Type a Template display name.
  6. (Optional) Add a Template description and upload a Thumbnail image for the template.
  7. Click Save.

You now have a custom template which you can select when creating new pages that support the original default template. Such pages automatically start with the page builder content stored within the custom template, and can then be further adjusted. Changes made in the content of one page do NOT affect the content of other pages that use the same custom page template.

Managing existing page templates

You can see a list of all custom page templates on your site in the Page templates (MVC) application. In this application you can Delete () custom page templates.