AEM Templates
Understand AEM templates — the foundation of every page. Learn the difference between static and editable templates and how they shape the author experience.
Last reviewed: December 2024
🔍 What Is It?
In AEM, every page is based on a template. A template defines:
- →Page structure — the layout, zones, and containers on the page
- →Page component — the Java/HTL code that renders the page
- →Allowed components — which components authors can add
- →Initial content — pre-populated content when a new page is created
- →Thumbnail — what authors see when choosing a template
There are two types of templates in AEM:
- Static Templates (legacy) — defined in code under
/apps, require developer changes - Editable Templates (modern) — created in AEM's UI, managed by template authors
New projects should always use Editable Templates.
🎯 Why Do We Need It?
Templates solve the "blank page problem." Without templates:
- →Every new page would start completely empty
- →Authors would have to rebuild the header, footer, and navigation on every page
- →There would be no consistency across pages
- →Developers would need to be involved in every page creation
With templates:
- →Authors pick a template and get a page that's already structured
- →Header and footer are locked in — consistent across all pages
- →Only appropriate components are available for each page type
- →New pages are created in seconds, not hours
🏗️ What Happens in Real Projects?
A typical enterprise AEM project has multiple templates:
- →Home Page Template — one per site, very structured
- →Article Template — for blog posts and news articles
- →Landing Page Template — flexible layout for campaigns
- →Product Page Template — structured for product information
- →Search Results Template — specific to search functionality
Template authors (usually senior content people or UX leads) create and maintain these templates. Developers build the underlying page components and components that templates use.
⚙️ How It Works
Static Templates (Legacy)
Stored in /apps/mysite/templates/. Each template is a node with:
- →
jcr:primaryType=cq:Template - →
sling:resourceType— points to the page component - →
allowedPaths— where this template can be used - →
ranking— order in the template picker
Editable Templates (Modern)
Stored in /conf/mysite/settings/wcm/templates/. Created through the Template Editor UI. Has three layers:
- →Structure — locked components (header, footer)
- →Initial Content — pre-populated editable content
- →Layout — responsive grid configuration
Template → Page Component → HTL
When a page is rendered, AEM:
- Reads the page's
sling:resourceType(set by the template) - Finds the page component at that path in
/apps - Runs the page component's HTL script
- The HTL script renders the page structure and includes child components
💻 Example
Static Template vs Editable Template — Comparing the two template approaches with real code examples.
🤔 Common Confusions
❓ What is the relationship between a template and a page component?
A template specifies which page component to use (via sling:resourceType). The page component provides the HTML structure (header, main, footer) and the rendering logic. The template is the configuration; the page component is the code.
❓ Can I change a page's template after it's created?
It's possible but complex. AEM doesn't have a built-in "change template" feature. You'd need to manually update the page's sling:resourceType and restructure the content. In practice, it's usually easier to create a new page with the correct template.
❓ What is allowedPaths in a static template?
It restricts where a template can be used. If allowedPaths is set to /content/mysite/en/articles(/.*)? then this template only appears in the page creation wizard when you're creating pages under /content/mysite/en/articles.
🚨 Common Production Issues
Template not appearing in page creation wizard
template is not enabled (for Editable Templates) or allowedPaths doesn't match the current location (for Static Templates).
Page renders blank
page component has an error. Check error.log for HTL or Sling Model exceptions.
Wrong template used for a page
check the page's sling:resourceType property in CRXDE.
Authors can create pages in the wrong site section
allowed templates or parent-page restrictions are too broad.
Template changes do not reach Publish
/conf template or policy content was changed but not published or packaged consistently across environments.
Header/footer missing after deployment
page component or Experience Fragment reference used by the template was not deployed, configured, or published.
✅ Best Practices
Always use Editable Templates for new projects
they're more flexible and don't require code changes.
Create a clear naming convention for templates (e.g., "Article Page", "Landing Page", "Product Page").
Limit the number of templates
too many templates confuse authors. Aim for flexibility through component configuration, not more templates.
Lock header and footer in the Structure layer so authors can't accidentally break the page structure.
Define allowed templates per site section so authors see only the templates that make sense for that content tree.
Treat /conf changes as governed content
review, package or publish, and test them before production rollout.
Document template ownership and approval flow because template changes can affect thousands of pages.
🏛️ Architect's Note
Templates are the governance layer of AEM. A well-designed template system gives authors freedom within boundaries — they can create diverse pages without breaking the design system.
Template Design Principle: Design templates to be as flexible as possible while maintaining brand consistency. The more templates you have, the more maintenance burden you create. Aim for 5–10 templates that cover all use cases through component flexibility.
💬 Frequently Asked Questions
🎯 Key Takeaways
🔗 Related Topics
🎯 Practice this topic in interviews
↗ Where this topic fits
AEM Technology Guide
Return to the AEM learning hub.
AEM Developer Career Path
This AEM developer career path explains how to become an AEM developer through JCR, Sling, HTL, client libraries, Dispatcher, Cloud Service delivery, project depth, and interview-ready enterprise implementation skills.
Drupal Developer Career Path
A practical route through Drupal content modeling, site building, theming, modules, configuration management, APIs, performance, deployment discipline, and interview preparation.
Sources
Sources / References
Use these AEM references to verify the concept in official docs and continue into the most relevant SplashRide pages.
Official documentation
Related SplashRide pages
SplashRide AEM learning path
Browse the full AEM topic collection and learning order on SplashRide.
AEM Interview Prep
Practice AEM interview questions and scenario-based answers.
AEM Developer Career Path
This AEM developer career path explains how to become an AEM developer through JCR, Sling, HTL, client libraries, Dispatcher, Cloud Service delivery, project depth, and interview-ready enterprise implementation skills.
Drupal Developer Career Path
A practical route through Drupal content modeling, site building, theming, modules, configuration management, APIs, performance, deployment discipline, and interview preparation.
Editable Templates
Learn how Editable Templates replaced static templates in AEM and how they give template authors control over page structure without developer involvement.
AEM Components Explained: Dialogs, HTL, Sling Models, and Core Components
Learn AEM components with component nodes, dialogs, HTL, Sling Models, Core Components, authoring, inheritance, and real project patterns.