Migrating Your Content Seamlessly: A Comprehensive Tech Guide from WordPress to Sitecore XM Cloud

Are you looking to make a smooth transition from WordPress to Sitecore XM Cloud? With the power of The RESTful API for the ItemService from Sitecore, you can effortlessly import your content using your favorite programming language, such as C#. Whether you're switching from WordPress, Umbraco, or any other system that can export data in a usable format like JSON, this blog post is your go-to resource for a successful migration.

Exploring the RESTful API

In this blog, we dive deep into the RESTful API for Sitecore, examining how to import content from simple one-page WordPress layouts into Sitecore. We'll also highlight that the RESTful API for XM Cloud mirrors that of Sitecore XP, making it a versatile tool for your content migration needs.

Content migration options

While the RESTful API is a powerful choice, there are alternative automation options that might be better suited for specific cases, each with its own set of advantages and disadvantages. Here's an overview of the available methods:

Sitecore RESTful API:

- Compatible with XM Cloud and Sitecore XP
- Basic API lacks advanced features
- With C#, it's easy to create logic that formats the data to fit in Sitecore
- Offers a very good Visual Studio debugger
- No issues with long-running processes as a Windows console application
- However, it lacks support for media

Sitecore Authoring and Management GraphQL API:

- Supports XM Cloud and Sitecore 10.3+
- Similar to REST API but includes media support
- A bit more challenging to set up and connect compared to REST API

Sitecore PowerShell:

- Usable for XM Cloud and Sitecore XP
- Runs in the Sitecore context, providing direct access to Sitecore native API
- Out-of-the-box support for long-running processes
- Some users may find it more difficult to write logic in PowerShell than in C#

Custom Import (Running in Sitecore Context):

- Requires creating logic for long-running processes
- Needs deployment to Sitecore for running
- Providing direct access to Sitecore native API

Sitecore Connect:

- Less suitable for one-time tasks
- Can be difficult to connect to the local computer

Choosing the right method

Content migration is typically a one-time task, but it's beneficial if the process is repeatable. For development purposes, easy debugging is crucial. The import can be performed on any Sitecore environment of your choice, and content can be exported using packages or item serialization. In terms of performance, all the mentioned solutions can create a few items per second. However, for XM Cloud, the GraphQL API is often a good choice.

The RESTful API solution

Below I provide tips and solutions for content migration with the Sitecore RESTful API. I will also provide insights into Sitecore Authoring and Management GraphQL API in a future blog post.

Authentication

Username and password… Yes, also on XM cloud. I was a bit surprised but that is how it works, just create a Sitecore account.

Branches

The RESTful API doesn’t support Sitecore Branches Templates, you need to create structure yourself.

Media

The API doesn’t support media uploading. You can store media on disk by creating one or more zip files. Just make sure the file size of the .zip is not much larger than 100Mb, otherwise it will be difficult to process in Sitecore. Use the Advance upload in Sitecore and check ‘unpack zip’. After uploading the media in Sitecore, you can use the RestFul API to check if a media is in Sitecore and you get the Sitecore Item Guid back, which you can use to refer the media.

For a media picker field, you can use this format: <image mediaid="{mediaguid}" />

For using media in rich text, you can use this format: -/media/[mediaguid important without braces and dashes!].ashx

Layout

You can use the __Renderings and __FinalRenderings field for the Layout, just put the layout XML into these fields. If needed you can use the Sitecore.Layout. LayoutDefinition from the Sitecore.Kernel to help construction the layout XML.

Ready to Get Started?

I've got a demo code for you, check out my GitHub repository for practical code that works seamlessly with XM Cloud. To make it work with Sitecore XP, you need to adjust the template GUID and the template models to fit. The code includes authentication, media handling, component management, and tags/references.

Let's get started!