All Articles

Sitecore Content Serialization (SCS) - Commands explained

Sitecore Content Serialization(SCS)

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

Installation

To use SCS, we need to install the Sitecore CLI first.

  1. Open Powershell/Command Prompt as Administrator.

  2. Change Directory to your project folder.

    cd C:\Path\to\your\project-folder
  3. Run the below commands:

    dotnet new tool-manifest
    dotnet tool install Sitecore.CLI
    dotnet sitecore init
  4. The files needed for the Sitecore Content Serialization will be initialized with the above commands. Run dotnet sitecore -h or dotnet sitecore --help to verify if the installation has succeeded. The command should print something as below:

    img

  5. You can create [Layer].[Name].module.json files for your each project as per your requirements to serialize your items.

Login Command

The login command is used to authenticate the CLI to a Sitecore instance.

1719219247368

If you already have configured the CLI, you would use the command directly:

dotnet sitecore login

Otherwise, you would have to pass it the Content Management and Identity Server URLs:

dotnet sitecore login --cm "https://<cm.instance.url>" --auth "https://<id.instance.url>"

You can also use the client-id & client-secret, for OAuth logins. And you can use client-credentials for your CI/CD.

Serialization Commands

1719219504549

1. pull command

The pull command can be used to pull items from your Sitecore instance to your solution.

1719219766031

To simply pull all configured items from Sitecore, you can run:

dotnet sitecore ser pull

To check what all items will be pulled on running the command, i.e. perform a dry run, you can use the --what-if option.

dotnet sitecore ser pull --what-if

You can use the -i or --include and -e or --exclude options, to include, exclude modules while pulling.

  • To pull all items related to the Article Feature, you would use:
    dotnet sitecore ser pull -i "Feature.Article"
  • To pull all items excluding the Project layer, you would use:
    dotnet sitecore ser pull -e "Project.*"
  • To pull all Foundation layer items:
    dotnet sitecore ser pull -i "Foundation.*"

2. push command

The push command can be used to push items from your solution to your Sitecore instance.

1719220543465

To simply push all serialized items to Sitecore, you can run:

dotnet sitecore ser push

To check what all items will be pushed on running the command, i.e. perform a dry run, you can use the --what-if option.

dotnet sitecore ser push --what-if

You can use the -i or --include and -e or --exclude options, to include, exclude modules while pushing.

  • To push all items related to the Article Feature, you would use:
    dotnet sitecore ser push -i "Feature.Article"
  • To push all items excluding the Project layer, you would use:
    dotnet sitecore ser push -e "Project.*"
  • To push all Foundation layer items:
    dotnet sitecore ser push -i "Foundation.*"

I will be writing more about the other commands, you can check all my posts related to Sitecore Content Serialization here.

Published Jun 12, 2024

Sitecore MVP Technology 2024-23. Web Developer with rich experience in Sitecore and ASP.NET MVC.