Managing page templates

All documents (pages) on Kentico websites are based on page templates. Templates define the basic structure and components of pages without the content added by editors.

To access the main management interface for all page templates in the system, open the Page templates application. The system organizes templates into categories. You can edit individual templates by selecting them in the category tree.

To edit the properties of the template assigned to a specific document in the Pages application:

  1. Select the document in the content tree
  2. Open the Properties -> Templates tab.
  3. Click Edit template properties.

OR

  1. Open the document’s Design tab.
  2. Right-click the green template header and click Edit template.

When editing templates, you can set the following page template properties on the General tab:

Page template property

Description

Template display name

The name of the template displayed to users in the administration interface.

Template code name

A unique identifier of the template.

Category

Sets the category where the template is stored in the page template catalog.

Template description

Here you can enter a description for the template. Users can see this description when selecting page templates in the catalog (for example when creating new pages).

Thumbnail

Allows you to set the image that represents the template in the page template selection catalog.

You can choose between two types of images:

  • Image - upload a standard image file (for example a png).
  • Font icon class - enter the name of a CSS class that defines a font icon.

Clone as ad-hoc for new documents

Only available if the Template type is Portal page.

When a user creates a new page with a template that has this option enabled, the system automatically creates an ad-hoc copy of the template and assigns it to the page. This allows users to immediately modify the design of the new page without affecting the default re-usable template.

Note: The system always clones templates as ad-hoc when creating wireframes, even if this setting is disabled for the assigned template.

Template type

The following types of page templates are available:

  • Portal page - functions as a portal engine page template.
  • ASPX page - uses the ASPX page template development model. The content is based on a standard ASPX web form. If selected, you need to specify the path to the source file in the File name property.
  • ASPX + Portal page - works the same way as the ASPX page option, but also supports portal engine functionality — managing web parts or widgets in predefined zones on the Design tab of the Pages application.
  • Dashboard page - provides a template for widget dashboard sections of the administration interface. This type of page template cannot be used for standard content tree pages.
  • MVC - template for creating pages defined through an MVC controller and action. You need to specify the controller and action via the Default controller and Default action properties. Pages based on MVC templates automatically use the live URL and view in editing mode (i.e. on the Page tab of the Pages application).
  • UI page - functions as a portal engine template for pages of the Kentico administration interface. You cannot assign UI page templates to normal website pages, only to UI elements.

Master template

Only available if the Template type is Portal page.

Indicates if the pages that use the template are designated as Master pages. Enabling this option also causes the template to be selectable as the root master page template in the New site wizard.

Page nesting

Only available if the Template type is Portal page.

Determines how documents based on the template display their content inside ancestor pages in the content tree.

  • All ancestor pages - nests within all ancestor pages in the content tree up to the nearest master page.
  • None - behaves as a standalone page without any nesting.
  • Only the nearest master page - nests only within the website’s master page. If the website uses multiple master pages, documents based on this template nest only within the closest master page in the content tree hierarchy.
  • Specific content tree levels - allows you to enable or disable nesting within specific levels of the content tree (represented by the checkboxes below). The actual nesting depends on the structure of the website where the template is used.

See: Inheriting portal engine page content

File name

Only available if the Template type is ASPX page or ASPX + Portal page.

Specifies the path to the .aspx file that serves as the page template’s source. You can either choose the using the Select button, or enter the path manually. The tilde character (~) represents the root directory of the project folder, e.g. ~/CMSTemplates/CorporateSite/Blog.aspx

Default controller

Only available if the Template type is MVC.

Sets the name of the controller class containing the MVC action that the system performs when pages using this template are accessed.

Do not type the Controller suffix of the class name. For example, if the class is called NewsMVCController, enter NewsMVC.

The system first searches for the specified class in the CMS.Controllers.<current site code name> namespace. If the class cannot be found there, the CMS.Controllers.Global namespace is searched.

Default action

Only available if the Template type is MVC.

Specifies the exact action defined within the controller class that the system performs when loading pages based on the template.

Limiting the use of page templates

When editing page templates in the Page templates application, you can:

  • Assign templates to specific websites on the Sites tab. Users can only work with the template on the selected websites.
  • Add further limitations through template scopes (by default, page templates can be used anywhere on the websites to which they are assigned).

Scopes simplify the user experience by reducing the number of templates available for selection in specific parts of the website. To define scopes for a page template:

Important: Template scopes are not a security feature. After assigning a template to a page, users can move the page to a location that is not allowed by the given template’s scopes.

  1. Open the Scopes tab of the template’s editing interface.

  2. Select Template can be used only within the following scopes.

  3. Choose the Site where the scope will apply.

    • You can only choose the sites to which the template is assigned.
    • Global scopes are valid on all sites in the system.
  4. Click New template scope.

  5. Set the parameters of the scope:

    • Starting path - defines a sub-section of the website where the template can be used. Allows the exact document with the entered path and all of its descendants (subpages).
    • Document type - allows the template only for documents of the selected type.
    • Culture - allows the template for document versions in the selected culture (language).
    • Levels - you can allow the template only for documents on specific levels in the content tree hierarchy.
  6. Click Save.

You can add any number of scopes for each template. Users can select the template for documents that fulfill the requirements of at least one of the scopes.

Allowing a template only for Page (menu item) documents in the English culture, on the first two levels of the content tree

Defining head content for templates

You can add custom head content for page templates, such as links to external CSS stylesheets or JavaScript files. 

  1. Open the page template’s editing interface.
  2. Switch to the Header tab.
  3. Type in the required head content.
  4. Click Save.

The system inserts the content into the <head> element in the output code of all pages that use the given template.

For documents that use portal engine templates, the head content can also be inherited by subpages. The inheritance depends on the following options, which you can enable on the Header tab of each page template:

  • Allow descendant templates to inherit the header - if enabled, the head content of the template can be inherited by documents on lower levels in the content tree.
  • Inherit headers from the templates of ancestor documents - indicates if documents based on the template are allowed to inherit head content from the templates of documents that are above them in the content tree.

Note: The header inheritance works according to the page nesting settings of documents — pages can only inherit head content from ancestor pages where they are nested. This way, the system only adds the head content to pages that actually display the page template containing the header definition.

Finding which documents use a given template

To view a list of all documents (pages) in the system that use a specific page template, open the Documents tab of the template’s editing interface.

You can access individual documents in the list through the following actions:

  • Edit document - opens the document in the Edit mode of the Pages application.
  • Navigate to document - opens the page on the live site.

Editing the XML source of a template’s web parts

The system stores the content and configuration of web parts placed on page templates as XML data. If you cannot use the Design tab due to an error caused by an incorrectly configured web part, you can fix the issue on the Web parts tab of the given page template’s editing interface. The tab allows you to edit the XML source directly.

  • You can modify the values of properties for all web parts on the template.
  • You can remove web parts from the template by deleting entire <web part> elements.