1

What is the exact difference between static and editable template? I read everywhere that "Once a page is created using static templates, after that if we make any change in static template it wouldn't affect the page.".

I have an AEM 6.5 system with me where pages are created by using static templates. When I add a component or make any change to the static template script (like adding a class to a div) the changes are reflected across all pages. Then why its said static template don't affect exisiting pages.

Thank you

sushmita
  • 13
  • 3

1 Answers1

2

Once a page is created using static templates, after that if we make any change in static template it wouldn't affect the page

That description does not refer to scripts, it refers to the content defined by the template. Templates themselves don't contain any scripts but they reference components that do. When you add a div, it is to a page-level component that a template references by its sling:resourceType.

A Static Template in AEM can be thought of as a bit of content with which to initialise a new page based on that template. It comes as a .content.xml file with serialised JCR data. It defines the basic properties of a new page, including, but not limited to, the resource type of the component with which to render the page, paragraph systems, components placed on the page by default, etc. These templates are edited through code. Once a page is created based on such a template, the content is copied.

Changing the page-level component (by adding a div) works because all pages based on the template still have the same sling:resourceType applied to their jcr:content node in the repository.

Changing the template itself, e.g. by adding a text component to a paragraph system somewhere in the template's .content.xml won't affect existing pages.

An Editable Template allows you to maintain a relationship where changes to the template's structure are automatically reflected by every page based on the template. This only applies to the template's Structure, edited in the Structure mode. Editable templates also allow you to define Initial content which behaves much like the content of a static template in that it's copied once at the point of page creation. To be more precise, the initial content is merged with the structure, which can be a little difficult to reason about initially.

toniedzwiedz
  • 17,895
  • 9
  • 86
  • 131