Managing page templates
All pages on Kentico websites, with the exception of pages based on content-only page types, 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 page in the Pages application:
- Select the page in the content tree
- Open the Properties -> Template tab.
- Click Edit template properties.
– OR –
- Open the page’s Design tab.
- 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:
|
Clone as ad-hoc for new pages |
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. |
Template type |
The following types of page templates are available:
|
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 pages based on the template display their content inside ancestor pages in the content tree.
|
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 |
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.
Open the Scopes tab of the template’s editing interface.
Select Template can be used only within the following scopes.
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.
Click New template scope.
Set the parameters of the scope:
- Starting path - defines a sub-section of the website where the template can be used. Allows the exact page with the entered path and all of its descendants (subpages).
- Page type - allows the template only for pages of the selected type.
- Culture - allows the template for page versions in the selected culture (language).
- Levels - you can allow the template only for pages on specific levels in the content tree hierarchy.
Click Save.
You can add any number of scopes for each template. Users can select the template for pages that fulfill the requirements of at least one of the scopes.
Defining head content for templates
You can add custom head content for page templates, such as links to external CSS stylesheets or JavaScript files.
- Open the page template’s editing interface.
- Switch to the Header tab.
- Type in the required head content.
- Click Save.
The system inserts the content into the <head> element in the output code of pages that use the given template. Note that head content is only rendered on pages whose page type has the Behaves as Page (menu item) type property enabled.
For pages 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 pages on lower levels in the content tree.
- Inherit headers from the templates of ancestor pages - indicates if pages based on the template are allowed to inherit head content from the templates of pages that are above them in the content tree.
Note: The header inheritance works according to the page nesting settings of pages – 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 pages use a given template
To view a list of all pages in the system that use a specific page template, open the Pages tab of the template’s editing interface.
You can access individual pages in the list through the following actions:
- Edit page** - opens the page in the Edit mode of the Pages application.
- Navigate to page** - 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.