BLOG

Img
Rohan Bhateja Author's Perspective
img
3 Minute read

Sitecore 10 Content Serialization

Introduction

Sitecore Content Serialization (SCS) is a system to serialize, share, and deploy content items and keeping them in version control. This functionality is designed to help teams of developers that work on the same Sitecore solution to synchronize database changes between their individual development environments.

Serialization functionality in Sitecore has been there for a long time. The release of Sitecore 10 has launched eye-catching features in its updated OOTB serialization. The changes introduced in Sitecore version 10 are developer-focussed that lay emphasize on proper implementation of serialization.

In the earlier versions, developers used multiple tools such as TDS, Unicorn, Sitecore Packages to share the items while working in a team. In Sitecore 10 version, dependency on other Version Control System such as Unicorn has been eliminated. Now, the .YAML format has been introduced for each item.

Sitecore Content Serialization (SCS) comes with JSON based configurations in which we have certain options to configure/choose while including and excluding the items.

Modes to Serialize

Combining the best of TDS and Unicorn, SCS gives 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 VS -A graphical tool to interact with Sitecore using Visual Studio.

Install Sitecore Management Service

You must install the Sitecore Management Service package to your CM instance and you can download the package from Sitecore CLI Download page and directly install this package to Sitecore Instance.

Install Sitecore CLI

Before installing CLI, make sure you have installed 3.1 version of .Net Core because the

"dotnet new-tool manifest"

command is available only in .Net Core 3+ version.

Create a new project in Visual Studio and make sure you follow the Helix Architecture and go to the Project folder

(C:\Users\rohanb\source\repos\Example10)

in my case and open the PowerShell in administrator mode and run the following commands :

dotnet new tool-manifest

dotnet tool install Sitecore.CLI --add-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json

# To install the Sitecore CLI as a global tool (not recommended):

dotnet tool install Sitecore.CLI -g --add-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json

Install Sitecore CLI Commands

After successful installation, you can verify it using

"dotnet sitecore"

because as per Sitecore installation document, you have to hit only

"sitecore"

but it throws an error.

Login to Sitecore Instance with SCLI Interface

There are two ways to login into Sitecore using SCLI-

  1. An interactive user login, using device code flow.
  2. A non-interactive client login, using client credentials flow.

Interactive User Login

Before logging into Sitecore, we have to initialize SCLI as mentioned below:

  • Open the Powershell in administrator mode and go to the Project Folder and run the following command-

"dotnet sitecore init"

  • As you hit this command in the file system, you can see the sitecore.json file and .sitecore folder.

  • Now, login into sitecore and run this command (change the parameters accordingly)-

"dotnet sitecore login --auth
https://sc10identityserver.dev.local --cm
https://sc10sc.dev.local --allow-write true"

  • Once you hit this command, a Sitecore login window will start opening in your browser and click Yes, Allow.

  • Now create a file under your project folder Serialization.modules.json in my case and add the following details:

Remember, if you are adding multiple paths then do have the templates on the top else you will get an error while deserialization.

  • After setting all this, use the below serialization command for the push & pull activities where ‘ser’ is the shorthand for the serialization keyword. After running the pull command, you can see the YML files in file system.

"dotnet sitecore ser pull"
"dotnet sitecore ser push"

  • For other command or the help section, run the command as mentioned below:

"dotnet sitecore --help"

Ebook
Sitecore CMS for Multi-site implementation

Conclusion:

The fact that SCS is a more developer-friendly format, Sitecore 10 content serialization allows to transform data items to text files or memory buffers for their future storage, transfer and reconstruction. It is especially useful for a team of developers who work together on the same project and need to seamlessly synchronize changes between their individual development environments. Few cases in which Serializing is better than Packaging are :-

  • There is no size limit in serializing the items but while creating Sitecore Packages, there is a size limit of 2GB only.
  • There are no revert option in Sitecore Packaging, once you have installed the item package you will lose the changes which you don't want to but with the serialization you can anytime revert the changes (use revert item or revert tree) and get back to the initial state of the content item.

Happy Serializing!!

Rohan Bhateja Senior Associate at Altudo


Talk to our Experts

Talk to us about how we bring together 1:1 personalisation, deep Martech Expertise, CX & Demand Gen Strategy, Engagement Analytics & Cross-Channel Orchestration to drive award winning experiences that convert

Get in touch for a complimentary consultation or a demo today.

Expert Workshops

Free workshops, expert advice & demos- to help your realize value with Sitecore

Register

Session Presentations

  • Sitecore + SFMC= Marketing Success
  • Transforming The Future Of eCommerce
Meet Us

Giveaways:

Participate in our event survey , meet us at our booth , get free giveaways & a chance to win an iPhone 11

Let’s go
Close Button