**Template**: determines **page structure*and **authoring regions**. **Policy**: determines **allowed components*+ **default/design options*+
Templates & Policies
Summary
- Template: determines page structure and authoring regions.
- Policy: determines allowed components + default/design options + Style System.
- Together they create a governed authoring experience — authors have freedom within boundaries.
Main Storage:
Static vs Editable Templates
cq:template points to /apps/... path with cq:Template node → using static template. New projects — and all of AEMaaCS — must use editable templates.
Template Type
Template type = blueprint for editable templates. It defines:
- Which page component renders the page
- Initial structure (locked components every page gets)
- Initial content (default content for new pages)
- Initial policies (default component policies)
Usually seeded via code packages and then managed in the UI.
Creating an Editable Template (UI)
Tools → General → Templates:
- Select config folder (
/conf/<site>) - Create → select Template Type (e.g.
Page) - Set title (e.g.
Article Page) + name - Open Template Editor → configure 3 modes
3 Modes in Template Editor
Checklist:
- Structure
- Layout container (responsive grid) for main region
- Header/footer locked (if used)
- Allowed components (via policy) for appropriate regions
- Initial
- Placeholder components (title, empty hero, pre-configured list…)
- Policies
- Allowed components per container
- Style System groups (theme/spacing/size…)
- Design dialog/policy fields of components (if applicable)
Locked components show a lock icon — authors cannot move/delete/configure them.
Page Component (top-level renderer)
Every page in AEM is rendered by a page component — generating complete HTML documents.
Key elements:
- Head — meta tags, CSS includes
- Header/Footer — included as fixed components (
data-sly-resource) - Main content area — responsive grid where authors drop components
- Client libraries — CSS in head, JS before
</body>
Proxy Page Component (Recommended)
Inherit Core Components page instead of rewriting everything.
Override using extension points instead of rewriting the entire page:
Core Components page uses data-sly-include to look for these files in the resource type path. Since proxy component sets sling:resourceSuperType, Sling script resolution checks your component first then falls back to Core Component — placing files in your page component folder is sufficient.
Only override extension points while Core Components page handles HTML structure, SEO meta tags, and boilerplate.
Templates as Code (persist /conf)
Templates, template types, and policies reside under /conf. UI changes only exist on that environment until exported to the codebase.
- Build content package with filters pointing to template/policy paths:
- Commit exported XML into
ui.content(or separateui.confmodule). - Redeploy Dev/Stage/Prod — templates stay identical across all environments.
Failure to persist → UI-only changes are lost on subsequent deployments (if /conf is overwritten), causing environments to drift.
Component Policies
Policies configure component behavior in templates. Per template, per container. Stored at /conf/<site>/settings/wcm/policies/ — useful for debugging or export.
Allowed Components
- Template editor → Structure mode
- Click layout container
- Click policy icon (wrench)
- Allowed Components — select allowed component groups/individual components
Prevents components from being placed in wrong regions — e.g. Hero not placed in sidebar.
Design Dialog (Policy) Values — currentStyle
Some components have design dialogs (policy dialogs) configuring default settings per template context:
- Text — default rich text formatting options
- Image — allowed image widths, lazy loading defaults
- Container — layout options, background colors
Style System
Allows authors to apply CSS classes to components without developer intervention.
- Template editor → select component
- Open policy
- Styles → add style groups:
Each option maps to a CSS class (e.g. cmp-hero--large, cmp-hero--dark). Authors select styles in component toolbars — no code changes needed.
All changes made via browser UI must be exported + persisted into git repository; otherwise they will be lost on redeploy.
Responsive Grid (Layout Container)
Primary layout mechanism:
- Drag-and-drop placement
- 12-column grid
- Column resizing in authoring UI (Layout mode — ruler icon)
- Breakpoints for responsive behavior
Breakpoints configured in responsive grid policy (template editor → layout container → policy → breakpoint widths). Custom breakpoints can be defined in policy node wcm/foundation/components/responsivegrid under /conf.
Proxy Components
Most components in a project are proxy components inheriting Core Components — generated automatically by Maven archetype:
Benefits:
- Reuse — all Core Component functionality for free
- Customization — override any part (dialog, HTL, model) in proxy
- Versioning — update Core Components without breaking overrides
Linking Site ↔ Templates
Templates must be enabled for site config (/conf/<site>):
- Tool: Tools → General → Templates
- Templates created here are available for pages under
/content/mysite/ - Sites and templates connect via
jcr:contentof site root:
cq:conf— connects site to config folder containing templates/policies.cq:allowedTemplates— multi-value property regex patterns set on content root (typically site root or section folder).
Template only appears in Create Page dialog if path matches pattern and template is Enabled. "No templates available" → check cq:allowedTemplates first, then check template enabled/published status.
Set via UI: Page Properties → Advanced → Template Settings (Allowed Templates).
Page Creation Flow
When an author creates a page:
Quick Debug (JCR paths)
Official Documentation
- Page Templates — Editable (Experience League)
- Creating Page Templates (developer)
- Style System
- WKND Tutorial — Pages & Templates
- Templates & Policies | Luca Nerlich