DEV Community

Rob Earlam for Sitecore

Posted on • Originally published at on

Migrating the Sitecore MVP site to XM Cloud – Part 2

Migrating the Sitecore MVP site to XM Cloud

This is the second part in a four part blog series about migratin the Sitecore MVP Site from Sitecore XM 10.2 to Sitecore XM Cloud, you can view the other posts in the series here:

Custom Content Resolvers

One of the key differences between working headlessly in Sitecore XM 10.2 and Sitecore XM Cloud is the introduction of Experience Edge. When working against Edge, there is no Web Database and there are no Content Delivery (CD) servers. Instead, when you publish a snapshot of your layout data is stored in our Content Delivery Network (CDN), this enables super-fast, low-latency, globally scaled delivery of your content to your head. However, it does change how you must think about your development processes.

When working with XM headless development, a common process would be to customise the Layout Service to match your requirements using Custom Content Resolvers, these would then be deployed to your CD servers and your custom code would be executed on each request. You might be wondering how you can achieve this same effect when working against Edge now there are no CD servers in this architecture. Well, the quick answer is you can’t follow the same process, so you need to change how you think about these customisations.

Do you really need a Custom Content Resolver?

Now in the original version of the Sitecore MVP site, we had a whole heap of Custom Content Resolvers. If you take our Navigation feature for example, we had three different renderings for the Footer, TopLinks and MainNav components. You can see here that all three of them were created using Custom Content Resolvers: .

So, we started to look at the Content Resolvers that are provided out of the box and realised that with a bit of tweaking of our rendering model, we could get the same functionality with those. With XM Cloud you get the following Content Resolves provided out of the box, and these will cover a large number of scenarios you’ll end up running into:

  • Context Item Children Resolver
  • Context Item Resolver
  • Datasource Item Children Resolver
  • Datasource Resolver
  • Folder Filter Resolver

A good example of this is our Footer, we have the copyright text and the social links that are all content managed:

MVP Site footer navigation bar

Now in the old site, we had custom code to get a list of items for the social links, and another item had a text field containing the copyright text. To change this to work with an OOTB Content Resolver we simply moved these items to a single datasource item. This enabled us to then make use of the Datasource Resolver instead. So, you’ll need to perform this same sort of refactoring if you have any Custom Content Resolvers in use.

This also gives benefits looking forwards though, as we’re removing customisations from our implementation. That means we have a smaller footprint of functionality that exists in our codebase, meaning that we have less code to test should we end up upgrading or doing any large-scale refactors of the MVP head, this is a big win!

What about complex functionality?

This approach of pivoting to using OOTB Content Resolvers will work for a lot of common content scenarios, but what happens if you have renderings that are more complex, that can’t be handled by the OOTB resolvers? Well in this case you’re going to need to push this functionality down into you head instead. We had a scenario just like this where we wanted to render out the MVP Directory and I’ll go into more detail on what we had to do to migrate this functionality in part 3….

Top comments (0)