CommunityTemplateDefinition defines an Experience Builder site template. It brings together an assigned theme, mappings between template pages and theme-layout pages, and descriptive information shown in the Experience Creation Wizard. It represents a template, not the complete configuration of an existing site.
Salesforce Digital Experiences must be enabled in the org for this metadata type to be available. The template references separately defined components, including CommunityThemeDefinition and FlexiPage; changing a template mapping is different from changing the theme or page itself.
Key Elements
| Element | What the Element Controls |
|---|---|
masterLabel |
Required. The template label displayed in Setup. |
baseTemplate |
The only valid value is c. |
category |
Required. The optimized use case for the template. Allowed values are Commerce, IT, Marketing, Sales, and Service. |
defaultThemeDefinition |
Required. References the assigned CommunityThemeDefinition. |
defaultBrandingSet |
References the associated BrandingSet. This element is read-only on the template; configure the association through CommunityThemeDefinition. |
pageSetting |
Contains nested CommunityTemplatePageSetting entries. Each entry requires page and themeLayout, both of which reference FlexiPage components. |
bundlesInfo |
Contains nested CommunityTemplateBundleInfo entries describing preview images and feature highlights for the Experience Creation Wizard. |
type within bundlesInfo
|
Required. Allowed values are PreviewImage, supporting up to three entries, and Highlight, supporting up to four entries. |
image within bundlesInfo
|
References a ContentAsset. Required for PreviewImage; optional for Highlight. |
order within bundlesInfo
|
Required. Position among entries of the same type, starting at 1. The maximum is 3 for PreviewImage and 4 for Highlight. |
title within bundlesInfo
|
Required. The title of the entry to use in code. |
enableExtendedCleanUpOnDelete |
Defaults to false. When true, deleting the template attempts to delete directly or indirectly referenced components automatically. |
publisher |
The publisher name shown in the Change Theme wizard. If omitted, Salesforce uses the name of the org from which the package was originally exported. |
Behavior and Constraints
The assigned theme is required, but the template's branding association is read-only. Set defaultThemeDefinition to the assigned theme definition. Do not treat defaultBrandingSet as a writable template setting; configure that association through CommunityThemeDefinition.
Each pageSetting connects two separately defined pages. Its page identifies the template page, and its themeLayout identifies the theme-layout page. Both values reference FlexiPage components. The mapping does not embed either page's definition.
The bundlesInfo entries supply descriptive information included in the template export and used by the Experience Creation Wizard. CommunityTemplateBundleInfo and CommunityTemplatePageSetting are nested structures within the template, not separate deployable components.
The order value controls presentation within each bundle-info type. For example, a Highlight and a PreviewImage can both have order set to 1 because they occupy positions in separate groups. This is display order, not execution order.
Deployment and Retrieval
CommunityTemplateDefinition files use the .communityTemplateDefinition suffix and reside in the communityTemplateDefinitions directory. The type inherits fullName from Metadata; masterLabel supplies the label displayed in Setup.
In the package.xml manifest, use CommunityTemplateDefinition as the type name and a component name, such as MyTemplate, as the member. The type also supports the * wildcard. See the Metadata API reference.
Dependency analysis must distinguish the template's references from the definitions of the referenced theme, pages, and images. These relationships identify connected components, but they do not establish a mandatory deployment sequence. Retrieving the template should not be treated as retrieving the complete configuration of an existing site.
Deletion scope depends on enableExtendedCleanUpOnDelete. Its default is false. When set to true, deleting the template attempts to delete directly or indirectly referenced components, such as CommunityThemeDefinition, FlexiPage, and StaticResource.
Extended cleanup can therefore be a broader destructive operation than removing the template definition alone. It is an attempt, not a guarantee that every referenced component will be deleted. The actual scope depends on the template's references.
Relationships
The template points to its assigned theme, branding set, preview assets, and page mappings. Navigation is represented by NavigationMenu, whose container can reference the template. A LightningBolt can also reference the template through its name element.
References
-
BrandingSet:defaultBrandingSet, which is read-only on the template. -
CommunityThemeDefinition:defaultThemeDefinition. -
ContentAsset:imagewithinbundlesInfo. -
FlexiPage:pageandthemeLayoutwithinpageSetting.
Referenced By
-
LightningBolt:name. -
NavigationMenu:container.
Reported Issues
-
A missing-page error on the template can follow a failure to deploy the referenced page. In a 2016 report involving a Napili-derived template package, component-access and
CaseArticleerrors occurred onFlexiPagecomponents, followed by a missing-FlexiPage error onCommunityTemplateDefinition. The author reported that enabling Knowledge at the org level resolved the deployment; making the deploying user a Knowledge user alone was insufficient. This is a conditional finding for Knowledge-dependent template pages, not a Knowledge prerequisite for every template. Template packaging discussion. -
Missing CSS in a template retrieval does not establish that the customization was lost. A 2024 community report located custom CSS in the
customCSSproperty of anExperienceBundletheme JSON file atforce-app/main/default/experiences/{yourProject}/themes/{yourTheme}.json. For a site represented byExperienceBundle, this is a separate configuration location fromCommunityTemplateDefinition. Custom CSS location report.
Common Questions
Does CommunityTemplateDefinition contain my entire Experience Builder site?
No. It defines a site template, including the assigned theme reference, page-to-theme-layout mappings, and wizard presentation information. The referenced theme and pages are separately defined components.
Why does deployment say that a referenced FlexiPage is missing?
The referenced page may itself have failed to deploy. In the reported Knowledge-dependent template case, page-level component-access and CaseArticle errors preceded the template's missing-page error. Enabling Knowledge at the org level resolved that particular deployment.
Will deleting a template also delete its pages and theme?
With enableExtendedCleanUpOnDelete set to true, deletion attempts to remove directly or indirectly referenced components, including themes and pages. The default is false, and extended cleanup does not guarantee that every referenced component will be deleted.
Can I change defaultBrandingSet in the template metadata?
No. defaultBrandingSet is read-only on CommunityTemplateDefinition. Configure the branding association through CommunityThemeDefinition.
Where is my site's custom CSS if it is not in the template retrieval?
For a site represented by ExperienceBundle, a community report located it in the customCSS property of the theme JSON file. That configuration is separate from the template definition.