Create custom templates in the backend

Overview

A page template defines the structure and the common content that a set of pages share, for example, a header with navigation, a footer, and a content area. When you change the template, all pages based on it are updated.

You create custom ASP.NET Core page templates in the Sitefinity CMS backend and design them in the New page editor, using the Section widget and the content widgets. You do not need to write code.

If you need full control over the HTML markup of the template, or you need to add your own styles, scripts, and placeholders, base your template on a layout file from the Renderer project. For more information, see Create custom templates based on layout files.

PREREQUISITES: You have set up the ASP.NET Core Renderer. For more information, see Develop with ASP.NET Core.

Create the template

To create a custom page template, perform the following:

  1. In the main menu of the backend, click Design » Page Templates.
    The Templates grid opens.

  2. Click Create a template.

  3. In Template name, enter a name for the template.

  4. In Name used in the code (for developers), enter the name that developers use to refer to the template in code.
    This field is required.

  5. Under Template thumbnail, click Edit (Change) to select the thumbnail that represents the template in the backend.
    You can select one of the predefined thumbnails or upload your own image.

  6. Click Continue.
    The Select a base template page opens. The templates are grouped by the framework they use.

  7. Under .NET Core templates, select Default.
    To base your template on a layout file from the Renderer project or on another ASP.NET Core template, select it from the same group.

    NOTE: The new template inherits the framework of its base template. If you select a template from another group, for example, Bootstrap5, you create an MVC template that opens in the Layout editor.

RESULT: The template is created in status Draft and opens in the New page editor.

Design the template layout

When you open a new template that is based on the Default template, it is empty. You build the layout of the template with the Section widget and then add content widgets in the sections.

Add sections

  1. Click Add section here....
    The Select widget pane opens on the Layout tab.
  2. Click Section.
    The section is added to the template.
  3. To configure the columns, spacing, and background of the section, hover over the section and click its label.
    For more information, see Design the layout with the Section widget.
  4. To add more sections, hover over the top or bottom border of an existing section and click Add section.

Add widgets

  1. In a section, click Add widget here....
    The Select widget pane opens on the Content tab. The widgets are grouped by category, for example, Basic, Lists, Dynamic experiences, Marketing, and AI search.
  2. Select a widget and configure it.

Add the widgets that you want to display on all pages that use the template, for example, the navigation, the logo, and the footer content.

View the template structure

To view the hierarchy of the sections and widgets in the template, open the Template structure pane in the upper-right corner of the editor. You can use it to find and select sections and widgets in complex layouts.

Save and publish the template

When you finish designing the template, do one of the following:

  • To keep the template as a draft, click Save as Draft.
  • To make the template available for pages, click Publish.

To see how the template looks to site visitors, click Preview.

Manage the template

In the editor, expand More options (More options). You can perform the following actions:

  • Title & properties
    Change the name, the name used in the code, and the thumbnail of the template.

  • Duplicate
    Create a copy of the template. For more information, see Duplicate page templates.

  • Lock layout
    Prevent editors from adding, moving, or removing widgets on the root level of pages and templates based on this template. For more information, see Restrict templates and sections from editing.

  • Share with...
    Share the template with other sites. For more information, see Share page templates.

  • Change base template
    Select another base template from the same framework.

  • Set permissions
    Define which users and roles can view and modify the template.

  • Revision history
    View and restore previous versions of the template. For more information, see Revision history of page templates.

  • Delete
    Delete the template.

    IMPORTANT: When you delete a template, all of its child templates and all pages that use it are also deleted.

You can also manage your templates in the Templates grid. For more information, see Templates grid.

Use the template

Create a page based on the template

  1. In the main menu of the backend, click Pages and then click Create a page.
  2. Enter the title of the page and click Continue.
  3. On the Select a template step, select your template.
    The page opens in the New page editor. The page displays the sections and widgets from the template, and you can add page-specific content.

For more information, see Create pages.

Create nested templates

You can base a new template on your custom template. This way, you define the common elements once, in the parent template, and add more specific elements in the child templates. To do this, follow the procedure in Create the template and, on the Select a base template page, select your custom template.

Changes that you make to the parent template are applied to its child templates. For more information, see Create page templates.

Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.