Effective Content Serialization in Sitecore XM Cloud
Effective Content Serialization in Sitecore XM Cloud
Introduction
Serialization in Sitecore XM Cloud is critical for deploying, backing up, and syncing content items between development and production environments. By organizing serialization through modular .module.json files, teams can efficiently control and automate complex multisite projects.
How Serialization Works in XM Cloud
Sitecore Content Serialization uses two primary config files:
- sitecore.json: Located at the root of your solution, this file declares which .module.json modules should be active for serialization and sets general serialization preferences.
- .module.json files: These define logical groupings of Sitecore content by item path, controlling serialization for templates, layouts, renderings, settings, and more.
Example .module.json Structure
A typical Feature or Project .module.json might look as follows:
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "Feature.Blog",
"items": {
"includes": [
{
"name": "BlogTemplates",
"path": "/sitecore/templates/Feature/Blog",
"scope": "ItemAndDescendants"
},
{
"name": "BlogRenderings",
"path": "/sitecore/layout/Renderings/Feature/Blog",
"scope": "ItemAndDescendants"
},
{
"name": "BlogSettings",
"path": "/sitecore/system/Settings/Feature/Blog",
"scope": "ItemAndDescendants"
}
]
}
} Key Points for XM Cloud Content Serialization
- Only custom items (not vanilla Sitecore items) should be included in module JSON files.
- Use path and scope rules to target specific parts of the content tree (e.g., Project/Feature templates, layouts, media folders, renderings).
- Combine multiple .module.json files under logical folders (Feature, Project, etc.) for modular development.
- The scope field controls whether to serialize only the item, its children, or all descendants.
- Serialization is triggered either by the Sitecore CLI tool or as part of the cloud deployment process, ensuring environments (Dev, QA, Staging) are consistent.
Important Configuration Controls
- allowedPushOperations: Restricts what actions (create, update, delete) occur when synchronizing content.
- Sitecore CLI is used for pushing/pulling serialized items between the local environment and XM Cloud.
- Additional configuration, like excluding standard fields or custom module references, can be set in sitecore.json or in each .module.json file.
Modular Approach for the xxx Site
The use of separate .module.json files for Sitecore XM Cloud serialization is best practice for scalable, modular, and maintainable content management. These files enable fine-grained control over what is serialized, organized across different solution layers (Content, Template, Layout, System, Core, and Root), directly supporting robust DevOps and team workflows.
Why Separate .module.json Files?
- Modularity: Dividing content into distinct module files (e.g., site content, templates, layouts, system settings) allows teams to work independently on different areas with minimal merge conflicts.
- Clarity & Control: Each file targets explicit paths and scopes, making it easy to understand what will be serialized and deployed. Rules per path (including, excluding, assigning scope, and controlling allowedPushOperations) are clearly stated.
- Versioning: Version control tools (Git) can efficiently track changes in individual modules, supporting rapid troubleshooting and deployments.
- Environment Consistency: Ensures only the necessary items are pushed to target environments, reducing risk and increasing predictability.
Typical Configuration Examples
Core Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "XXX.Core",
"items": {
"includes": [
{
"name": "Snippets",
"path": "/sitecore/system/Settings/Html Editor Profiles/Rich Text Full/Snippets",
"database": "core",
"scope": "ItemAndDescendants"
}
]
}
} Template Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "XXX.Template",
"items": {
"includes": [
{
"name": "templates/Foundation",
"path": "/sitecore/templates/Foundation",
"rules": [
{
"path": "/ABC",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "*",
"scope": "Ignored"
}
]
},
{
"name": "templates/project",
"path": "/sitecore/templates/Project/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
},
{
"name": "templates/feature",
"path": "/sitecore/templates/Feature",
"rules": [
{
"path": "/ABC",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "*",
"scope": "Ignored"
}
]
},
{
"name": "templates/branches/project",
"path": "/sitecore/templates/Branches/Project/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
},
{
"name": "templates/branches/feature",
"path": "/sitecore/templates/Branches/Feature/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
}
]
}
} Layout Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "XXX.Layout",
"items": {
"includes": [
{
"name": "layout/renderings/feature",
"path": "/sitecore/layout/Renderings/Feature/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
},
{
"name": "layout/renderings/project",
"path": "/sitecore/layout/Renderings/Project",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
},
{
"name": "layout/placeholders",
"path": "/sitecore/layout/Placeholder Settings/Project",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
}
]
},
{
"name": "layout/foundation/placeholders",
"path": "/sitecore/layout/Placeholder Settings/Foundation/JSS Experience Accelerator/Placeholder Settings",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "layout/feature/placeholders",
"path": "/sitecore/layout/Placeholder Settings/Feature/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "layout/foundation/layout",
"path": "/sitecore/layout/Layouts/Foundation/JSS Experience Accelerator/Presentation",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "layout/renderings/jss",
"path": "/sitecore/layout/Renderings/Feature/JSS Experience Accelerator",
"rules": [
{
"path": "/Media",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "*",
"scope": "Ignored"
}
]
}
]
}
}System Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "XXX.System",
"items": {
"includes": [
{
"name": "system/aliases",
"path": "/sitecore/system/Aliases",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateOnly"
}
]
},
{
"name": "system/dictionary",
"path": "/sitecore/system/Dictionary",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateOnly"
}
]
},
{
"name": "system/languages",
"path": "/sitecore/system/Languages",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/workflows",
"path": "/sitecore/system/Workflows",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/Webhooks/Authorizations",
"path": "/sitecore/system/Settings/Webhooks/Authorizations",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/feature",
"path": "/sitecore/system/Settings/Feature/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/project",
"path": "/sitecore/system/Settings/Project/ABC",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/validation",
"path": "/sitecore/system/Settings/Validation Rules/Field Rules/Custom Rule",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/powershell/scripts",
"path": "/sitecore/system/Modules/PowerShell/Script Library/Custom",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
},
{
"name": "system/Tasks/Schedules",
"path": "/sitecore/system/Tasks/Schedules",
"rules": [
{
"path": "*",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
}
]
}
]
}
}Root Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "XXX.Root",
"items": {
"includes": [
{
"name": "root",
"path": "/sitecore/content/ABC",
"scope": "SingleItem",
"allowedPushOperations": "CreateOnly"
}
]
}
} Site Content Module
{
"$schema": "../.sitecore/schemas/ModuleFile.schema.json",
"namespace": "Content.XXX",
"items": {
"includes": [
{
"name": "XXX/site",
"path": "/sitecore/content/ABC/XXX",
"rules": [
{
"path": "/Home",
"scope": "SingleItem"
},
{
"path": "/Media",
"scope": "Ignored"
},
{
"path": "/Data",
"scope": "ItemAndChildren"
},
{
"path": "/GlobalData",
"scope": "ItemAndChildren"
},
{
"path": "/Dictionary",
"scope": "SingleItem"
},
{
"path": "/Presentation",
"scope": "Ignored"
},
{
"path": "/Settings",
"scope": "ItemAndChildren"
},
{
"path": "/SearchDataSources",
"scope": "Ignored"
}
]
},
{
"name": "XXX/presentation",
"path": "/sitecore/content/ABC/XXX/Presentation",
"rules": [
{
"path": "/Available Renderings",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "/Headless Variants",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "/Page Branches",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateAndUpdate"
},
{
"path": "/Styles",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "/Partial Designs",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "/Placeholder Settings",
"scope": "ItemAndDescendants",
"allowedPushOperations": "CreateUpdateAndDelete"
},
{
"path": "*",
"scope": "Ignored"
}
]
}
]
}
} Best Practices Illustrated
- Selective Serialization: Including and excluding with precision improves performance, backup speed, and reduces errors.
- Operation Control: Using allowedPushOperations protects important site data from unwanted changes during deployments.
- Modular Separation: Each site, project feature, template, and system area uses its own .module.json, driving clarity for large teams and automations.
Conclusion
Using modular serialization files like site.content.module.json empowers Sitecore XM Cloud projects to scale, automates deployments, and keeps multisite environments consistent and reliable. This approach should be the standard for anyone working with advanced XM Cloud setups.
Note: For more details, refer to the official documentation here:👉 Sitecore Content Serialization
Comments
Post a Comment