CommunityThemeDefinition defines a theme for an Experience Builder site. It maps theme layout types to layout configurations and can include branding, home-page layout overrides, and descriptive information used when exporting a theme.
A theme definition is distinct from the layout components it references and from the site's experience metadata. Its references do not prove that a particular site currently uses the theme, and retrieving this type alone does not confirm that Experience Builder custom CSS has been captured.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The inherited metadata identity of the component, distinct from its display label. |
masterLabel |
Required. The label displayed in Setup. |
publisher |
The publisher name displayed in the Experience Builder site-creation wizard. If omitted, it uses the name of the org from which the package was originally exported, not necessarily the destination org. |
defaultBrandingSet |
References the branding properties associated with the theme, as configured in the Experience Builder Theme panel. |
enableExtendedCleanUpOnDelete |
Defaults to false. When true, deleting the theme definition attempts to delete directly or indirectly referenced components automatically. |
themeSetting |
Required list that associates layout types with layout configurations. |
themeSetting.themeLayout |
Required in each setting. Identifies the configuration and layout for that setting. |
themeSetting.themeLayoutType, themeSetting.customThemeLayoutType
|
Exactly one is required per setting. The documented standard values for themeLayoutType are Inner, Home, and Login. The custom selector identifies a custom layout type instead. |
customThemeLayoutType.label |
Required for each custom layout type declared in the top-level customThemeLayoutType list. The names Inner, Home, and Login are reserved. |
themeRouteOverride |
Selects a different layout type for the home page. Each entry requires exactly one of themeLayoutType or customThemeLayoutType, together with the required page selectors. |
themeRouteOverride.pageType |
Required. The only documented valid value is comm__standardPage. |
themeRouteOverride.pageAttributes |
Required. The only documented valid value is the JSON string {"PageName":"Home"}. |
bundlesInfo |
Optional export information. If supplied, it must include at least one preview image and one highlight. Each entry requires title, type, and order. |
bundlesInfo.type, bundlesInfo.image
|
type accepts PreviewImage or Highlight. A PreviewImage entry also requires image. A theme supports up to three preview images and four highlights. |
bundlesInfo.order |
The position among entries of the same type, beginning at 1. The maximum position is 3 for preview images and 4 for highlights. |
Behavior and Constraints
This metadata type is available only when Salesforce Digital Experiences is enabled in the org.
Layout configuration has three separate operations:
-
Declare a custom layout type: add an entry to the top-level
customThemeLayoutTypelist, with its requiredlabel. -
Associate a type with a layout: add a
themeSettingcontainingthemeLayoutand exactly one standard or custom type selector. The nestedcustomThemeLayoutTypestring selects a custom type; it does not declare one. -
Change the home page's selected type: add a
themeRouteOverrideforcomm__standardPagewithpageAttributesset to{"PageName":"Home"}, and exactly one type selector.
A route override therefore changes which layout type the home page selects. Changing that override is different from changing the layout associated with the selected type in themeSetting. The documented override mechanism is limited to the home page; it is not a general-purpose mechanism for arbitrary routes.
In both themeSetting and themeRouteOverride, the standard and custom type selectors are mutually exclusive. Supplying both does not meet the field constraints, and omitting both leaves the required selection unspecified.
The entries in bundlesInfo describe the exported theme. Their order values control presentation within each entry type, not execution. A highlight and a preview image can each occupy position 1; they do not share one combined sequence.
Deployment and Retrieval
Components use the .communityThemeDefinition suffix and are stored in the communityThemeDefinitions folder. In a package.xml manifest, the type name is CommunityThemeDefinition. This type supports the * wildcard for selecting components.
The deployment scope depends on the theme's actual references and which referenced components already exist in the destination org. A theme can connect to branding, layout components, and image assets, but the possible reference destinations are not a requirement to deploy every destination type.
Preview-image assets should not be assumed to use one metadata type. The image element has a recognized ContentAsset reference, while Salesforce's package example includes its preview-image identifier as a StaticResource. That example also packages the theme with a BrandingSet and its referenced FlexiPage layouts.
Deletion can affect more than the theme definition. When enableExtendedCleanUpOnDelete is true, deletion attempts to remove directly or indirectly referenced components, including components such as FlexiPage. This is attempted extended cleanup, not a guarantee that every referenced component will be deleted. The setting defaults to false.
Retrieving CommunityThemeDefinition alone is not proof that Builder custom CSS has been backed up. For sites represented by experience theme JSON, a community report places that CSS in the site's experience metadata rather than in this definition.
Relationships
CommunityTemplateDefinition can select a default theme, which in turn connects to branding and layout components. These connections describe possible metadata references, not proof of current site usage or a mandatory deployment sequence.
References
-
BrandingSet:defaultBrandingSet. -
ContentAsset:imagewithinbundlesInfo. -
FlexiPage:themeLayoutwithinthemeSetting. -
LightningBundle:themeLayoutwithinthemeSetting. -
LightningWebComponent:themeLayoutwithinthemeSetting.
The three destinations listed for themeLayout are alternatives recognized for that reference; a setting does not require all three.
Referenced By
-
CommunityTemplateDefinition:defaultThemeDefinition.
Documentation Inconsistencies
The exposed enumeration for themeLayoutType in both themeSetting and themeRouteOverride includes ServiceNotAvailable, while Salesforce's field documentation lists only Inner, Home, and Login. The applicability of ServiceNotAvailable is not documented.
Reported Issues
-
A theme-definition retrieval alone does not confirm that custom CSS was captured. An October 2024 community report located Builder custom CSS in the
customCSSproperty atforce-app/main/default/experiences/{yourProject}/themes/{yourTheme}.json. This finding applies to sites represented in that form and does not establish CSS storage behavior for every site configuration. See the custom CSS location report.
Common Questions
Does retrieving CommunityThemeDefinition back up Experience Builder custom CSS?
Not by itself. For sites represented by experience theme JSON, a community report identifies the customCSS property in the site's theme JSON. Retrieving the theme definition alone is not confirmation that this CSS was included.
How do I change the theme layout used by the home page?
Use themeRouteOverride to select the home page's layout type, with pageType set to comm__standardPage and pageAttributes set to {"PageName":"Home"}. Use themeSetting to associate that selected type with its layout configuration.
Can deleting a CommunityThemeDefinition delete its layouts?
Yes, deletion can attempt to remove referenced components such as FlexiPage when enableExtendedCleanUpOnDelete is true. The cleanup can extend to indirect references, but it is not guaranteed to delete every referenced component. The default is false.
Which dependencies must I deploy with a CommunityThemeDefinition?
The relevant components depend on the actual references and what already exists in the destination org. Connections can include branding, layouts, and image assets. The possible destinations for themeLayout do not mean that every theme requires all three layout component types.
Can I retrieve all CommunityThemeDefinition components with a wildcard?
Yes. This type supports * in the package.xml manifest. Its components use the .communityThemeDefinition suffix in the communityThemeDefinitions folder.