> For AI agents: the complete documentation index is available at https://nhanbe.id.vn/llms.txt, the full documentation bundle is available at https://nhanbe.id.vn/llms-full.txt.

# Templates and Policies

**Editable Templates** are AEM's modern template system. They let template authors define page structure, allowed components, and default content visually - without developer intervention. **Policies** attach reusable configuration to components and pages within a template context, controlling everything from allowed heading levels to loaded clientlibs.

<svg id="mermaid-svg-3016695" width="100%" xmlns="http://www.w3.org/2000/svg" style="max-width: 356.35418701171875px;" viewBox="0 0 356.35418701171875 618" role="graphics-document document" aria-roledescription="flowchart-v2"><g><marker id="mermaid-svg-3016695_flowchart-v2-pointEnd" viewBox="0 0 10 10" refX="5" refY="5" markerUnits="userSpaceOnUse" markerWidth="8" markerHeight="8" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-pointStart" viewBox="0 0 10 10" refX="4.5" refY="5" markerUnits="userSpaceOnUse" markerWidth="8" markerHeight="8" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-pointEnd-margin" viewBox="0 0 11.5 14" refX="11.5" refY="7" markerUnits="userSpaceOnUse" markerWidth="10.5" markerHeight="14" orient="auto"><path d="M 0 0 L 11.5 7 L 0 14 z" style="stroke-width: 0; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-pointStart-margin" viewBox="0 0 11.5 14" refX="1" refY="7" markerUnits="userSpaceOnUse" markerWidth="11.5" markerHeight="14" orient="auto"><polygon points="0,7 11.5,14 11.5,0" style="stroke-width: 0; stroke-dasharray: 1, 0;"></polygon></marker><marker id="mermaid-svg-3016695_flowchart-v2-circleEnd" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-3016695_flowchart-v2-circleStart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-3016695_flowchart-v2-circleEnd-margin" viewBox="0 0 10 10" refY="5" refX="12.25" markerUnits="userSpaceOnUse" markerWidth="14" markerHeight="14" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 0; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-3016695_flowchart-v2-circleStart-margin" viewBox="0 0 10 10" refX="-2" refY="5" markerUnits="userSpaceOnUse" markerWidth="14" markerHeight="14" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 0; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-3016695_flowchart-v2-crossEnd" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-crossStart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-crossEnd-margin" viewBox="0 0 15 15" refX="17.7" refY="7.5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 1,1 L 14,14 M 1,14 L 14,1" style="stroke-width: 2.5;"></path></marker><marker id="mermaid-svg-3016695_flowchart-v2-crossStart-margin" viewBox="0 0 15 15" refX="-3.5" refY="7.5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 1,1 L 14,14 M 1,14 L 14,1" style="stroke-width: 2.5; stroke-dasharray: 1, 0;"></path></marker><g><g></g><g><path d="M138,82L138,89.833C138,97.667,138,113.333,138,128.333C138,143.333,138,157.667,138,164.833L138,172" id="mermaid-svg-3016695-L_TT_Template_0" style=";" data-edge="true" data-et="edge" data-id="L_TT_Template_0" data-points="W3sieCI6MTM4LCJ5Ijo4Mn0seyJ4IjoxMzgsInkiOjEyOX0seyJ4IjoxMzgsInkiOjE3Nn1d" data-look="classic" marker-end="url(#mermaid-svg-3016695_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M184.238,274L191.63,281.833C199.021,289.667,213.805,305.333,221.197,320.333C228.589,335.333,228.589,349.667,228.589,356.833L228.589,364" id="mermaid-svg-3016695-L_Template_Policy_0" style=";" data-edge="true" data-et="edge" data-id="L_Template_Policy_0" data-points="W3sieCI6MTg0LjIzNzkwMTYzNzk1MTUyLCJ5IjoyNzR9LHsieCI6MjI4LjU4ODU0MTk4NDU1ODEsInkiOjMyMX0seyJ4IjoyMjguNTg4NTQxOTg0NTU4MSwieSI6MzY4fV0=" data-look="classic" marker-end="url(#mermaid-svg-3016695_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M91.762,274L84.37,281.833C76.979,289.667,62.195,305.333,54.803,327.167C47.411,349,47.411,377,47.411,405C47.411,433,47.411,461,55.37,482.38C63.329,503.76,79.247,518.52,87.206,525.9L95.165,533.28" id="mermaid-svg-3016695-L_Template_Page_0" style=";" data-edge="true" data-et="edge" data-id="L_Template_Page_0" data-points="W3sieCI6OTEuNzYyMDk4MzYyMDQ4NDgsInkiOjI3NH0seyJ4Ijo0Ny40MTE0NTgwMTU0NDE4OTUsInkiOjMyMX0seyJ4Ijo0Ny40MTE0NTgwMTU0NDE4OTUsInkiOjQwNX0seyJ4Ijo0Ny40MTE0NTgwMTU0NDE4OTUsInkiOjQ4OX0seyJ4Ijo5OC4wOTc5MDQxMjU4NDk0LCJ5Ijo1MzZ9XQ==" data-look="classic" marker-end="url(#mermaid-svg-3016695_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M228.589,442L228.589,449.833C228.589,457.667,228.589,473.333,220.63,488.547C212.671,503.76,196.753,518.52,188.794,525.9L180.835,533.28" id="mermaid-svg-3016695-L_Policy_Page_0" style=";" data-edge="true" data-et="edge" data-id="L_Policy_Page_0" data-points="W3sieCI6MjI4LjU4ODU0MTk4NDU1ODEsInkiOjQ0Mn0seyJ4IjoyMjguNTg4NTQxOTg0NTU4MSwieSI6NDg5fSx7IngiOjE3Ny45MDIwOTU4NzQxNTA2LCJ5Ijo1MzZ9XQ==" data-look="classic" marker-end="url(#mermaid-svg-3016695_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path></g><g><g transform="translate(138, 129)"><g data-id="L_TT_Template_0" transform="translate(-61.3125, -22)"><foreignObject width="122.625" height="44"><p>defines structure</p></foreignObject></g></g><g transform="translate(228.5885419845581, 321)"><g data-id="L_Template_Policy_0" transform="translate(-24.588542938232422, -22)"><foreignObject width="49.177085876464844" height="44"><p>assigns</p></foreignObject></g></g><g transform="translate(47.411458015441895, 405)"><g data-id="L_Template_Page_0" transform="translate(-26.41145896911621, -22)"><foreignObject width="52.82291793823242" height="44"><p>creates</p></foreignObject></g></g><g transform="translate(228.5885419845581, 489)"><g data-id="L_Policy_Page_0" transform="translate(-36.96354293823242, -22)"><foreignObject width="73.92708587646484" height="44"><p>configures</p></foreignObject></g></g></g><g><g id="mermaid-svg-3016695-flowchart-TT-0" data-look="classic" transform="translate(138, 45)"><rect style="" x="-125.93229675292969" y="-37" width="251.86459350585938" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-95.93229675292969, -22)"><rect></rect><foreignObject width="191.86459350585938" height="44"><p>Template Type (developer)</p></foreignObject></g></g><g id="mermaid-svg-3016695-flowchart-Template-1" data-look="classic" transform="translate(138, 225)"><rect style="" x="-130" y="-49" width="260" height="98" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-100, -34)"><rect></rect><foreignObject width="200" height="68"><p>Editable Template (template author)</p></foreignObject></g></g><g id="mermaid-svg-3016695-flowchart-Policy-2" data-look="classic" transform="translate(228.5885419845581, 405)"><rect style="" x="-119.765625" y="-37" width="239.53125" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-89.765625, -22)"><rect></rect><foreignObject width="179.53125" height="44"><p>Component / Page Policy</p></foreignObject></g></g><g id="mermaid-svg-3016695-flowchart-Page-3" data-look="classic" transform="translate(138, 573)"><rect style="" x="-81.9375" y="-37" width="163.875" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-51.9375, -22)"><rect></rect><foreignObject width="103.875" height="44"><p>Authored Page</p></foreignObject></g></g></g></g></g><defs></defs><defs></defs><linearGradient id="mermaid-svg-3016695-gradient" gradientUnits="objectBoundingBox" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="#cccccc" stop-opacity="1"></stop><stop offset="100%" stop-color="hsl(180, 0%, 18.3529411765%)" stop-opacity="1"></stop></linearGradient></svg>

***

## Why Editable Templates?

Editable Templates replaced the legacy **Static Templates** (`cq:Template`, design mode, `/etc/designs/`). Key advantages:

| Feature                     | Editable Templates                | Static Templates (legacy)     |
| --------------------------- | --------------------------------- | ----------------------------- |
| **Who creates templates**   | Template authors (non-developers) | Developers only               |
| **Structure changes**       | Visual editor (no code deploy)    | Code change + deploy          |
| **Component configuration** | Policies (per-template)           | Design mode (global)          |
| **Storage**                 | `/conf/` (content)                | `/etc/designs/` (code)        |
| **Initial content**         | Visual authoring                  | JSP/HTML in code              |
| **Allowed components**      | Per-container, per-template       | Global or per-component-group |
| **AEMaaCS**                 | Fully supported                   | Deprecated                    |

***

## Architecture

### How templates, types, and pages relate

<svg id="mermaid-svg-1163791" width="100%" xmlns="http://www.w3.org/2000/svg" style="max-width: 956.2396240234375px;" viewBox="-20.4375 0 956.2396240234375 544" role="graphics-document document" aria-roledescription="flowchart-v2"><g><marker id="mermaid-svg-1163791_flowchart-v2-pointEnd" viewBox="0 0 10 10" refX="5" refY="5" markerUnits="userSpaceOnUse" markerWidth="8" markerHeight="8" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-pointStart" viewBox="0 0 10 10" refX="4.5" refY="5" markerUnits="userSpaceOnUse" markerWidth="8" markerHeight="8" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-pointEnd-margin" viewBox="0 0 11.5 14" refX="11.5" refY="7" markerUnits="userSpaceOnUse" markerWidth="10.5" markerHeight="14" orient="auto"><path d="M 0 0 L 11.5 7 L 0 14 z" style="stroke-width: 0; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-pointStart-margin" viewBox="0 0 11.5 14" refX="1" refY="7" markerUnits="userSpaceOnUse" markerWidth="11.5" markerHeight="14" orient="auto"><polygon points="0,7 11.5,14 11.5,0" style="stroke-width: 0; stroke-dasharray: 1, 0;"></polygon></marker><marker id="mermaid-svg-1163791_flowchart-v2-circleEnd" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-1163791_flowchart-v2-circleStart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-1163791_flowchart-v2-circleEnd-margin" viewBox="0 0 10 10" refY="5" refX="12.25" markerUnits="userSpaceOnUse" markerWidth="14" markerHeight="14" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 0; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-1163791_flowchart-v2-circleStart-margin" viewBox="0 0 10 10" refX="-2" refY="5" markerUnits="userSpaceOnUse" markerWidth="14" markerHeight="14" orient="auto"><circle cx="5" cy="5" r="5" style="stroke-width: 0; stroke-dasharray: 1, 0;"></circle></marker><marker id="mermaid-svg-1163791_flowchart-v2-crossEnd" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-crossStart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-crossEnd-margin" viewBox="0 0 15 15" refX="17.7" refY="7.5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 1,1 L 14,14 M 1,14 L 14,1" style="stroke-width: 2.5;"></path></marker><marker id="mermaid-svg-1163791_flowchart-v2-crossStart-margin" viewBox="0 0 15 15" refX="-3.5" refY="7.5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 1,1 L 14,14 M 1,14 L 14,1" style="stroke-width: 2.5; stroke-dasharray: 1, 0;"></path></marker><g><g><g id="mermaid-svg-1163791-subGraph2" data-look="classic"><rect style="" x="660.1354064941406" y="8" width="267.66668701171875" height="404"></rect><g transform="translate(664.1354064941406, 8)"><foreignObject width="259.66668701171875" height="44"><p>Content author-managed (/content)</p></foreignObject></g></g><g id="mermaid-svg-1163791-subGraph1" data-look="classic"><rect style="" x="317.4375" y="8" width="359.125" height="528"></rect><g transform="translate(321.4375, 8)"><foreignObject width="351.125" height="44"><p>Template author-managed (/conf/.../templates)</p></foreignObject></g></g><g id="mermaid-svg-1163791-subGraph0" data-look="classic"><rect style="" x="-12.4375" y="8" width="350.875" height="528"></rect><g transform="translate(-8.4375, 8)"><foreignObject width="342.875" height="44"><p>Developer-managed (/conf/.../template-types)</p></foreignObject></g></g></g><g><path d="M244.964,80L257.136,80C269.309,80,293.655,80,309.994,80C326.333,80,334.667,80,343,80C351.333,80,359.667,80,368.825,80C377.983,80,387.965,80,392.957,80L397.948,80" id="mermaid-svg-1163791-L_TT_Template_0" style=";" data-edge="true" data-et="edge" data-id="L_TT_Template_0" data-points="W3sieCI6MjQ0Ljk2MzUzOTEyMzUzNTE2LCJ5Ijo4MH0seyJ4IjozMTgsInkiOjgwfSx7IngiOjM0MywieSI6ODB9LHsieCI6MzY4LCJ5Ijo4MH0seyJ4Ijo0MDEuOTQ3OTE0MTIzNTM1MTYsInkiOjgwfV0=" data-look="classic" marker-end="url(#mermaid-svg-1163791_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M293,216L297.167,216C301.333,216,309.667,216,318,216C326.333,216,334.667,216,343,216C351.333,216,359.667,216,370.393,216C381.12,216,394.24,216,400.799,216L407.359,216" id="mermaid-svg-1163791-L_TTStructure_Structure_0" style=";" data-edge="true" data-et="edge" data-id="L_TTStructure_Structure_0" data-points="W3sieCI6MjkzLCJ5IjoyMTZ9LHsieCI6MzE4LCJ5IjoyMTZ9LHsieCI6MzQzLCJ5IjoyMTZ9LHsieCI6MzY4LCJ5IjoyMTZ9LHsieCI6NDExLjM1OTM3NSwieSI6MjE2fV0=" data-look="classic" marker-end="url(#mermaid-svg-1163791_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M248.979,464L260.483,464C271.986,464,294.993,464,310.663,464C326.333,464,334.667,464,343,464C351.333,464,359.667,464,368.589,464C377.51,464,387.021,464,391.776,464L396.531,464" id="mermaid-svg-1163791-L_TTPolicy_Policies_0" style=";" data-edge="true" data-et="edge" data-id="L_TTPolicy_Policies_0" data-points="W3sieCI6MjQ4Ljk3OTE2NDEyMzUzNTE2LCJ5Ijo0NjR9LHsieCI6MzE4LCJ5Ijo0NjR9LHsieCI6MzQzLCJ5Ijo0NjR9LHsieCI6MzY4LCJ5Ijo0NjR9LHsieCI6NDAwLjUzMTI1LCJ5Ijo0NjR9XQ==" data-look="classic" marker-end="url(#mermaid-svg-1163791_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M592.052,80L597.71,80C603.368,80,614.684,80,624.509,80C634.333,80,642.667,80,651,80C659.333,80,667.667,80,683.049,80C698.432,80,720.865,80,732.081,80L743.297,80" id="mermaid-svg-1163791-L_Template_Page_0" style=";" data-edge="true" data-et="edge" data-id="L_Template_Page_0" data-points="W3sieCI6NTkyLjA1MjA4NTg3NjQ2NDgsInkiOjgwfSx7IngiOjYyNiwieSI6ODB9LHsieCI6NjUxLCJ5Ijo4MH0seyJ4Ijo2NzYsInkiOjgwfSx7IngiOjc0Ny4yOTY4NzUsInkiOjgwfV0=" data-look="classic" marker-end="url(#mermaid-svg-1163791_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path><path d="M601,340L605.167,340C609.333,340,617.667,340,626,340C634.333,340,642.667,340,651,340C659.333,340,667.667,340,675.333,340C683,340,690,340,693.5,340L697,340" id="mermaid-svg-1163791-L_InitContent_Content_0" style=";" data-edge="true" data-et="edge" data-id="L_InitContent_Content_0" data-points="W3sieCI6NjAxLCJ5IjozNDB9LHsieCI6NjI2LCJ5IjozNDB9LHsieCI6NjUxLCJ5IjozNDB9LHsieCI6Njc2LCJ5IjozNDB9LHsieCI6NzAxLCJ5IjozNDB9XQ==" data-look="classic" marker-end="url(#mermaid-svg-1163791_flowchart-v2-pointEnd)" fill="none" stroke="currentColor"></path></g><g><g><g data-id="L_TT_Template_0" transform="translate(0, 0)"></g></g><g><g data-id="L_TTStructure_Structure_0" transform="translate(0, 0)"></g></g><g><g data-id="L_TTPolicy_Policies_0" transform="translate(0, 0)"></g></g><g><g data-id="L_Template_Page_0" transform="translate(0, 0)"></g></g><g><g data-id="L_InitContent_Content_0" transform="translate(0, 0)"></g></g></g><g><g id="mermaid-svg-1163791-flowchart-TT-0" data-look="classic" transform="translate(163, 80)"><rect style="" x="-81.96354293823242" y="-37" width="163.92708587646484" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-51.96354293823242, -22)"><rect></rect><foreignObject width="103.92708587646484" height="44"><p>Template Type</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-TTStructure-1" data-look="classic" transform="translate(163, 216)"><rect style="" x="-130" y="-49" width="260" height="98" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-100, -34)"><rect></rect><foreignObject width="200" height="68"><p>Structure (locked containers)</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-TTPolicy-2" data-look="classic" transform="translate(163, 464)"><rect style="" x="-85.97916793823242" y="-37" width="171.95833587646484" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-55.97916793823242, -22)"><rect></rect><foreignObject width="111.95833587646484" height="44"><p>Default policies</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-Template-3" data-look="classic" transform="translate(497, 80)"><rect style="" x="-95.05208587646484" y="-37" width="190.1041717529297" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-65.05208587646484, -22)"><rect></rect><foreignObject width="130.1041717529297" height="44"><p>Editable Template</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-Structure-4" data-look="classic" transform="translate(497, 216)"><rect style="" x="-85.640625" y="-37" width="171.28125" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-55.640625, -22)"><rect></rect><foreignObject width="111.28125" height="44"><p>Structure mode</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-InitContent-5" data-look="classic" transform="translate(497, 340)"><rect style="" x="-104" y="-37" width="208" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-74, -22)"><rect></rect><foreignObject width="148" height="44"><p>Initial Content mode</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-Policies-6" data-look="classic" transform="translate(497, 464)"><rect style="" x="-96.46875" y="-37" width="192.9375" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-66.46875, -22)"><rect></rect><foreignObject width="132.9375" height="44"><p>Policy assignments</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-Page-7" data-look="classic" transform="translate(793.96875, 80)"><rect style="" x="-46.671875" y="-37" width="93.34375" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-16.671875, -22)"><rect></rect><foreignObject width="33.34375" height="44"><p>Page</p></foreignObject></g></g><g id="mermaid-svg-1163791-flowchart-Content-8" data-look="classic" transform="translate(793.96875, 340)"><rect style="" x="-92.96875" y="-37" width="185.9375" height="74" fill="none" stroke="currentColor"></rect><g style="" transform="translate(-62.96875, -22)"><rect></rect><foreignObject width="125.9375" height="44"><p>Authored content</p></foreignObject></g></g></g></g></g><defs></defs><defs></defs><linearGradient id="mermaid-svg-1163791-gradient" gradientUnits="objectBoundingBox" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="#cccccc" stop-opacity="1"></stop><stop offset="100%" stop-color="hsl(180, 0%, 18.3529411765%)" stop-opacity="1"></stop></linearGradient></svg>

### JCR structure

```markdown
/conf/mysite/
├── settings/
│   └── wcm/
│       ├── template-types/                  ← Developer-defined
│       │   └── content-page/
│       │       ├── jcr:content
│       │       │   └── sling:resourceType = "mysite/components/page"
│       │       ├── structure/               ← Locked structure
│       │       │   └── jcr:content/root/
│       │       │       └── responsivegrid
│       │       ├── initial/                 ← Default content
│       │       └── policies/                ← Default policy mappings
│       │
│       ├── templates/                       ← Template author-managed
│       │   ├── content-page/
│       │   │   ├── jcr:content
│       │   │   │   ├── jcr:title = "Content Page"
│       │   │   │   ├── status = "enabled"
│       │   │   │   └── allowedPaths = ["/content/mysite/.*"]
│       │   │   ├── structure/
│       │   │   ├── initial/
│       │   │   └── policies/
│       │   └── landing-page/
│       │       └── ...
│       │
│       └── policies/                        ← Policy definitions
│           └── mysite/
│               ├── components/
│               │   ├── text/
│               │   │   └── default/         ← Policy for text component
│               │   │       ├── jcr:title = "Default Text Policy"
│               │   │       └── allowedFormats = ["bold", "italic", "links"]
│               │   └── image/
│               │       └── default/
│               └── page/
│                   └── default/             ← Page policy
│                       ├── clientlibs = ["mysite.base", "mysite.theme"]
│                       └── appResourcesPath = "/etc.clientlibs/mysite"
```

***

## Template Types

Template types are the **developer-defined blueprints** that template authors use to create templates. They define the locked structure and default policies.

### Creating a template type

```xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
          xmlns:cq="http://www.day.com/jcr/cq/1.0"
    jcr:primaryType="cq:Template"
    jcr:title="Content Page"
    jcr:description="Base template type for content pages"
    ranking="{Long}100"/>
```

```xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          xmlns:jcr="http://www.jcp.org/jcr/1.0"
          xmlns:cq="http://www.day.com/jcr/cq/1.0"
    jcr:primaryType="cq:Page">
    <jcr:content
        jcr:primaryType="cq:PageContent"
        sling:resourceType="mysite/components/page"
        cq:deviceGroups="[/etc/mobile/groups/responsive]">
        <root
            jcr:primaryType="nt:unstructured"
            sling:resourceType="wcm/foundation/components/responsivegrid">
            <responsivegrid
                jcr:primaryType="nt:unstructured"
                sling:resourceType="wcm/foundation/components/responsivegrid"/>
        </root>
    </jcr:content>
</jcr:root>
```

***

## Template Editor

The Template Editor (**Tools > General > Templates**) provides three modes:

### Structure Mode

Defines the **layout skeleton** of the page. Template authors can:

- Add layout containers (responsive grids)
- Lock or unlock containers (locked = authors cannot move/delete)
- Configure allowed components per container
- Set the page component (`sling:resourceType`)

### Initial Content Mode

Sets **default content** that every new page created from this template starts with. For example:

- A hero component with placeholder text
- A breadcrumb component
- A default footer fragment

Authors can modify this initial content when they create a page.

### Policies Mode

Assigns **policies** to the page and to individual components. This is where you configure:

- Which clientlibs the page loads
- Which RTE formats are allowed in text components
- Which image sizes are permitted
- Style System classes

***

## Page Policies

Page policies control **page-level settings** applied to all pages using a template.

### Common page policy properties

| Property                 | Description                                     |
| ------------------------ | ----------------------------------------------- |
| `clientlibs`             | Clientlib categories to load on every page      |
| `appResourcesPath`       | Path prefix for clientlib proxy resolution      |
| `htmlPageItemsConfig`    | Controls `<head>` and `<body>` element ordering |
| `responsive/breakpoints` | Responsive grid breakpoint configuration        |

### Setting page policy via JCR

```xml
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="My Site Page Policy"
    sling:resourceType="wcm/core/components/policy/policy"
    clientlibs="[mysite.base,mysite.components]"
    appResourcesPath="/etc.clientlibs/mysite"/>
```

### Reading page policies in Sling Models

```java
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;

@Model(adaptables = Resource.class)
public class PagePolicyModel {

    @Self
    private Resource resource;

    @OSGiService
    private ContentPolicyManager policyManager;

    public String[] getClientlibs() {
        ContentPolicy policy = policyManager.getPolicy(resource);
        if (policy != null) {
            return policy.getProperties().get("clientlibs", String[].class);
        }
        return new String[0];
    }
}
```

***

## Component Policies

Component policies provide **per-template configuration** for components. The same component can behave differently depending on which template it's used in.

### Example: Text component policy

A policy that restricts the Rich Text Editor to only bold, italic, and links:

```xml
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Restricted Text"
    sling:resourceType="wcm/core/components/policy/policy"
    textIsRich="{Boolean}true"
    allowedFormats="[bold,italic,links]"/>
```

### Example: Image component policy

```xml
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Standard Image Policy"
    sling:resourceType="wcm/core/components/policy/policy"
    allowedRenditionWidths="[320,640,1024,1280,1920]"
    disableLazyLoading="{Boolean}false"
    enableDmFeatures="{Boolean}false"/>
```

### Reading component policies in Sling Models

```java
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;

@Model(adaptables = SlingHttpServletRequest.class)
public class ImageModel {

    @Self
    private SlingHttpServletRequest request;

    @OSGiService
    private ContentPolicyManager policyManager;

    public int[] getAllowedWidths() {
        Resource resource = request.getResource();
        ContentPolicy policy = policyManager.getPolicy(resource);

        if (policy != null) {
            String[] widths = policy.getProperties()
                .get("allowedRenditionWidths", String[].class);
            if (widths != null) {
                return Arrays.stream(widths)
                    .mapToInt(Integer::parseInt)
                    .toArray();
            }
        }

        return new int[]{ 320, 640, 1024 }; // defaults
    }
}
```

### Using currentStyle in HTL

`currentStyle` is a global HTL binding of type `com.day.cq.wcm.api.designer.Style` that is available automatically in every component. It exposes the properties from the component's content policy, so no `data-sly-use` is needed:

```html
<div class="text ${currentStyle.cssClass}"
     data-max-length="${currentStyle.maxLength}">
    ${properties.text @ context='html'}
</div>
```

***

## Allowed Components

Template authors control which components are available per container:

### In the Template Editor

1. Open the template in Structure mode
2. Click on a layout container
3. Open the **Policy** dialog
4. Under **Allowed Components**, check the component groups or individual components

### Allowed component groups

```xml
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Content Container Policy"
    sling:resourceType="wcm/core/components/policy/policy"
    components="[group:mysite - Content,group:mysite - Media]"/>
```

### Per-container configuration

Different containers on the same template can have different allowed components:

```markdown
Template: Landing Page
├── Header container  → Only: Navigation, Logo, Search
├── Hero container    → Only: Hero, Video Hero
├── Content container → All content components
└── Footer container  → Only: Footer, Legal Text
```

***

## Style System

The **Style System** lets template authors assign CSS classes to components without developer intervention. It builds on top of component policies:

### Defining styles in a policy

```xml
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="nt:unstructured"
    jcr:title="Button Policy"
    sling:resourceType="wcm/core/components/policy/policy">
    <cq:styleGroups jcr:primaryType="nt:unstructured">
        <group1
            jcr:primaryType="nt:unstructured"
            cq:styleGroupLabel="Size">
            <styles jcr:primaryType="nt:unstructured">
                <small
                    jcr:primaryType="nt:unstructured"
                    cq:styleId="btn-sm"
                    cq:styleLabel="Small"
                    cq:styleClasses="btn-sm"/>
                <large
                    jcr:primaryType="nt:unstructured"
                    cq:styleId="btn-lg"
                    cq:styleLabel="Large"
                    cq:styleClasses="btn-lg"/>
            </styles>
        </group1>
        <group2
            jcr:primaryType="nt:unstructured"
            cq:styleGroupLabel="Color">
            <styles jcr:primaryType="nt:unstructured">
                <primary
                    jcr:primaryType="nt:unstructured"
                    cq:styleId="btn-primary"
                    cq:styleLabel="Primary"
                    cq:styleClasses="btn-primary"/>
                <secondary
                    jcr:primaryType="nt:unstructured"
                    cq:styleId="btn-secondary"
                    cq:styleLabel="Secondary"
                    cq:styleClasses="btn-secondary"/>
            </styles>
        </group2>
    </cq:styleGroups>
</jcr:root>
```

Authors select styles via the component toolbar. The selected classes are added to the component's wrapper element.

### Reading styles in Sling Models

```java
import com.adobe.cq.wcm.style.ComponentStyleInfo;

@Model(adaptables = SlingHttpServletRequest.class)
public class StyledComponent {

    @Self
    private SlingHttpServletRequest request;

    public String getAppliedStyles() {
        ComponentStyleInfo styleInfo = request.getResource()
            .adaptTo(ComponentStyleInfo.class);

        if (styleInfo != null) {
            return styleInfo.getAppliedCssClasses();
            // e.g., "btn-lg btn-primary"
        }
        return "";
    }
}
```

***

## Policy Mapping

Policies are mapped to components within a template via `cq:policy` references:

```markdown
/conf/mysite/settings/wcm/templates/content-page/policies/
├── jcr:content
│   ├── cq:policy = "/conf/mysite/settings/wcm/policies/mysite/page/default"
│   └── root/
│       └── responsivegrid/
│           ├── cq:policy = "/conf/mysite/settings/wcm/policies/mysite/containers/content"
│           └── cq:policyMapping = { ... }
```

The `cq:policy` property points to the policy definition node. The template editor manages these mappings automatically.

***

## Locking and Unlocking Structure

Template authors can **lock** containers and components in the structure:

| Lock state                        | Author can...                                                |
| --------------------------------- | ------------------------------------------------------------ |
| **Locked**                        | Cannot move, delete, or restructure (can still edit content) |
| **Unlocked (editable structure)** | Can add, move, and delete components                         |
| **Initial content only**          | Component is in initial content but not locked in structure  |

Locking is set via the `cq:editable` property on the structure node.

***

## Static Templates (Legacy)

For reference, legacy static templates use a different mechanism:

```markdown
/apps/mysite/templates/
└── content-page/
    ├── jcr:primaryType = "cq:Template"
    ├── jcr:title = "Content Page"
    ├── allowedPaths = "/content/mysite/.*"
    └── jcr:content/
        └── sling:resourceType = "mysite/components/page"

/etc/designs/mysite/
└── jcr:content/
    └── component-config...  ← Design mode configuration
```

> Static templates are **deprecated** on AEMaaCS. All new projects should use Editable Templates. Existing static templates continue to work but cannot be managed in the Template Editor.

***

## Multi-Site Template Governance

### Shared templates

Store templates in a shared `/conf/` location for use across multiple sites:

```markdown
/conf/global/settings/wcm/templates/    ← Available to all sites
/conf/brand-a/settings/wcm/templates/   ← Brand A only
/conf/brand-b/settings/wcm/templates/   ← Brand B only
```

### Template allowedPaths

Restrict which content paths can use a template:

```markdown
allowedPaths = ["/content/brand-a/.*"]
```

### Inheriting policies

Policies defined at a higher `/conf/` level are inherited by child configurations, allowing shared base policies with per-site overrides.

***

## Best Practices

### Let template authors own templates

Developers create template types; template authors create and manage templates. This separation enables faster iteration without code deployments.

### Use policies for component configuration

Never hardcode component settings. Use policies so template authors can adjust behaviour (allowed formats, image sizes, style options) per template.

### Keep template types minimal

A template type should define the bare structural skeleton. Template authors add the detail (initial content, specific policies, allowed components).

### Use the Style System instead of component variants

Instead of creating `hero-dark`, `hero-light`, and `hero-centered` as separate components, create one `hero` component with a Style System policy that adds CSS classes.

### Version /conf/ content in code

Include your template type definitions and default policy configurations in `ui.content` and deploy them via Cloud Manager. Template author changes live alongside this in the content repository.

***

## Common Pitfalls

| Pitfall                                | Solution                                                                                                                           |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Template not showing in "Create Page"  | Check `status` is `enabled` and `allowedPaths` matches the current content path                                                    |
| Component not available in a container | Open the template in Structure mode and check the container's policy for allowed components                                        |
| Policy values not picked up            | Verify the `cq:policy` reference on the template points to the correct policy node                                                 |
| Style System classes not applied       | Ensure the component's HTL wrapper includes the `data-sly-use.style` binding or uses Core Components (which include it by default) |
| Design mode settings ignored           | Editable Templates do not use `/etc/designs/`; migrate to policies                                                                 |
| Initial content not appearing          | Check the template's Initial Content mode; verify the components have content authored                                             |
| Template locked for editing            | Only users with `template-authors` group membership can edit templates                                                             |
