Sitecore Content Serialization (SCS) is a system for serializing, sharing, and deploying content items, as well as keeping them in version control.

SCS is designed to help teams of developers that work on the same Sitecore solution to synchronize database changes between their individual development environments.

Sitecore Content Serialization comets with JSON based configurations in which we have certain options to configure while including and excluding the items.

Modes to Serialize

 

Combining the best of TDS and Unicorn, SCS give us the flexibility to move the content between environments. For this, we have two different tools mentioned below

1.     Sitecore CLI – A command-line tool to interact with your Sitecore Instance.
2.     Sitecore for Visual Studio – A graphical tool to interact with Sitecore using Visual Studio.



Structural Overview

Serialize content items in and out of a Sitecore instance using the Sitecore Content Serialization (SCS) system. We need to configure which content items to include and which ones to exclude, and which operation to perform on the content items.

The SCS system serializes content items into your project folder as YAML files. The default path is \serialization relative to module files, but we can configure any path we want.

Project Configuration file 

The project configuration file is named sitecore.json. It has several properties including a modules property, serialization property.

{

  "$schema": "./.sitecore/schemas/RootConfigurationFile.schema.json",   

  "modules": [ "src/*/*.module.json" ],

  "variables": {},

    "serialization": {

      "defaultMaxRelativeItemPathLength": 120,

      "defaultModuleRelativeSerializationPath": "serialization"

   }

}

 

Manual and automatic Serialization

We can use manual serialization when we want to push or pull content items to or from a Sitecore instance on demand.

We can use automatic serialization to specify content items that you would like to have automatically serialized from a Sitecore instance to our file system when they are created and updated.

Including and excluding content Items

We single out subsets of content items for serialization with includes and rules. This is useful for repeating the serialization of particular parts of your content item tree.

We configure what and how content items are included and excluded from serialization in a module file such as Project.module.json

 

"items": {

  "includes": [

    {

      "name": "content",

      "path": "/sitecore/content/home"

    }

  ]

}

Rules

Rules are used to configure the serialization of content item tree. We configure rules with a path relative to the root path, the scope of content items to influence, and any alterations to the allowed push operations.

Example:

"items": {

  "includes": [

    {

      "name": "content",

      "path": "/sitecore/content/home",

      "rules": [

        {

           "path": "/products/legacy",

           "scope": "ignored"

        },

        {

           "path": "/products",

           "scope": "ItemAndDescendants",

           "allowedPushOperations": "createUpdateAndDelete"

        },

        {

           "path": "*",

           "scope": "ignored"

        }

      ]

    }

  ]

}

 

The rule system works by the first-match-wins principle, meaning that when a content item matches a rule, all subsequent rules are ignored:

  • The first rule tells SCS to ignore all content items in the /sitecore/content/home/products/legacy path.
  • The second rule tells SCS to serialize all content items in the /sitecore/content/home/products path. All subcontent items are included because the scope is ItemAndDescendants.
  • The third rule prevents SCS from serializing anymore /sitecore/content/home content items. The wildcard path of this rule matches all content items not matched by the previous rules, and the ignored scope prevents them from being serialized.