Creating a New Template

Creating editable templates is primarily done with the template console and template editor by a template author. This section gives an overview of this process and follows with a description of what occurs at a technical level.

For information on how to use editable templates in an AEM project see Creating an AEM project using Lazybones.

When creating an editable template you:

  1. Create a folder for the templates. This folder is not mandatory, but is recommended best practice.

  2. Select a template type. This type is copied to create the template definition.

    NOTE
    A selection of template types are provided out-of-the-box. You can also create your own site-specific template types, if necessary.
  3. Configure the structure, content policies, initial content, and layout of the new template.

    Structure

    • The structure lets you define components and content for your template.

    • Components defined in the template structure cannot be moved on a resulting page nor deleted from any resulting pages.

      • If you are creating a template in a custom folder outside of the We.Retail sample content, you can choose Foundation Components or use Core Components.
    • If you want page authors to be able to add and remove components, add a paragraph system to the template.

    • Components can be unlocked and locked again to let you define initial content.

    For details on how a template author defines the structure, see Creating Page Templates.

    For technical details of the structure, see Structure in this document.

    Policies

    • The content policies define the design properties of a component.

      • For example, the components available or minimum/maximum dimensions.
    • These policies are applicable to the template (and pages created with the template).

    For details on how a template author defines policies, see Creating Page Templates.

    For technical detail of policies, see Content Policies in this document.

    Initial Content

    • Initial Content defines content that appears when a page is first created based on the template.
    • Initial content can then be edited by page authors.

    For details on how a template author defines the structure, see Creating Page Templates.

    For technical details on initial content, see Initial Content in this document.

    Layout

    • You can define the template layout for a range of devices.
    • Responsive layout for templates operates as it does for page authoring.

    For details on how a template author defines the template layout, see Creating Page Templates.

    For technical details on template layout, see Layout in this document.

  4. Enable the template, then allow it for specific content trees.

    • A template can be enabled or disabled to make it available or unavailable to page authors.
    • A template can be made available or unavailable for certain page branches.

    For details on how a template author enables a template, see Creating Page Templates.

    For technical details on enabling a template, see Enabling and Allowing a Template for Use in this document

  5. Use it to create content pages.

    • When using a template to create a page, there is no visible difference and no indication between static and editable templates.
    • For the page author, the process is transparent.

    For details on how a page author uses templates to create a page, see Creating and Organizing Pages.

    For technical details on creating pages with editable templates, see Resultant Content Pages in this document.

TIP
Never enter any information that must be internationalized into a template. For internalization purposes, the localization feature of the Core Components is recommended.
NOTE
Templates are powerful tools to streamline your page creation workflow. However too many templates can overwhelm the authors and make page creation confusing. A good rule of thumb is to keep the number of templates under 100.
Adobe does not recommend having more than 1000 templates due to potential performance impacts.
NOTE
The editor client library assumes the presence of the cq.shared namespace in content pages. If it is absent, it results in the JavaScript error Uncaught TypeError: Cannot read property 'shared' of undefined.
All sample content pages contain cq.shared, so any content based on them automatically includes cq.shared. However, if you decide to create your own content pages from scratch without basing them on sample content, you must make sure to include the cq.shared namespace.
See Using Client-Side Libraries for further information.

Template Folders

For organizing your templates, you can use the following folders:

  • global
  • Site-specific
    The site-specific folders that you create to organize your templates are created with an account holding admin privileges.
NOTE
Even though you can nest your folders, when the user views them in the Templates console they are presented as a flat structure.

In a standard AEM instance, the global folder exists in the template console. This folder holds default templates and acts as a fallback if no policies and/or template-types are found in the current folder. You can add your default templates to this folder or create a folder (recommended).

NOTE
It is best practice to create a folder to hold your customized templates and not to use the global folder.
CAUTION
Folders must be created by a user with admin rights.

Template types and policies are inherited across all folders according to the following order of precedence:

  1. The current folder.
  2. Parent or parents of the current folder.
  3. /conf/global
  4. /apps
  5. /libs

A list of all allowed entries is created. If any configurations overlap ( path/ label), only the instance closest to the current folder is presented to the user.

To create a folder, do the following:

  • Programmatically or with CRXDE Lite
  • Using the Configuration Browser