Rebuilding a Legacy Page with My Migration Tool: An Anonymized SitecoreAI Migration Walkthrough

Technical Director
  • Twitter
  • LinkedIn

Part 4 of a five-part series on SitecoreAI migration and my new migration tool.

The most useful migration example is often one page that exposes the awkward parts.

In this case, the source page looked straightforward to a visitor: a hero, descriptive content, legal notes, FAQs and related cards. In Sitecore, those visible sections were assembled from many smaller items, shared content and presentation settings.

The new implementation had a clearer component model. A hero expected one data source. FAQs had an explicit parent-and-children structure. Legal content could be shared while its numbering belonged to the page using it.

This walkthrough adapts project migration code into an anonymized example. Names, paths and identities have been generalized. The page-composition work began as a focused proof that generated instructions for review; it should not be read as a claim that the same recipe has already migrated an entire site.

Start with the page the author and visitor recognize

The source structure was not a reliable guide to the intended target structure.

A heading could be one item, a paragraph another, and a button's URL and label could live on different items. Some sections referenced global content rather than local children. A generic container rendering could represent several different visual components.

I first needed a reviewed description of the page:

Visible sectionSource behaviorTarget composition
HeroSeparate text, image and button items.One Hero data source and rendering instance.
Text columnsHeading and multiple rich-text items.One Text Columns data source.
Product detailsA rich-text block combining heading and body.Separate target fields, with a declared conversion.
Legal notesShared disclaimer content with a page-specific selection order.Shared disclaimer items plus local numbered references.
FAQsOrdered question and answer bindings.FAQ collection, child entries and explicit order.
Related cardsA reference to a global component.A reusable target collection and card data.

That table described mapping decisions, not an automatic discovery algorithm. The source item bindings were checked against the actual page and content model.

Establish the page before replacing its composition

The page-creation entry handled the hierarchy and ordinary fields. It preserved the page's item ID, placed Home beneath the target site and retained structural folders needed by descendants.

Its field mapping deliberately omitted legacy presentation, workflow state, locks and source security settings. Target-owned configuration needed to remain under target control.

The page-composition entry was separate. It created the required data sources and updated the page's design assignment and English final presentation.

This division made the output easier to review. If the title was wrong, I could inspect the page-field mapping. If the hero appeared in the wrong place, I could inspect the composition and its referenced data source.

The example page lives beneath:

/sitecore/content/SiteCollection/Site/Home/products/example-product

New local data belongs below that page's Data item. Shared content belongs in the site's global Data branch.

Combine explicitly identified source items

The hero transformation assembled values from several source items.

The following method is a simplified project helper using the real V3 repository and field APIs. It is not a built-in hero-migration feature:

private static async Task<FieldContainer> BuildHeroAsync(
    IItemRepository source,
    Guid headingId,
    Guid bodyId,
    Guid imageId,
    CancellationToken cancellationToken)
{
    var heading = await source.GetFieldsAsync(
        headingId, cancellationToken: cancellationToken);
    var body = await source.GetFieldsAsync(
        bodyId, cancellationToken: cancellationToken);
    var image = await source.GetFieldsAsync(
        imageId, cancellationToken: cancellationToken);

    return new FieldContainer()
        .SetFirstVersion("en", "Heading",
            heading.GetLatestVersion("en", "Rich Text")
            ?? throw new InvalidOperationException("Missing hero heading."))
        .SetFirstVersion("en", "Body",
            body.GetLatestVersion("en", "Rich Text")
            ?? throw new InvalidOperationException("Missing hero body."))
        .SetFirstVersion("en", "Image",
            image.GetLatestVersion("en", "Image")
            ?? throw new InvalidOperationException("Missing hero image."));
}

The surrounding plugin supplies the reviewed source IDs and writes the returned fields to a target item with the correct template. This excerpt assumes the target Heading and Body fields accept the source rich text.

The source field scopes were checked explicitly. A shared link field and a versioned label field needed different accessors. A helper that tried shared, unversioned and versioned values until something appeared would hide mistakes in those bindings.

For a button, the project mapping combined the source link XML with its separately stored label. Keeping that operation structured preserved internal-link identities and other link attributes.

Give generated items stable identities

Keeping the page ID was straightforward. New data sources needed their own identities, and allocating random IDs on every run would create duplicates.

The project solution derived an ID from a stable source identity and a role. Here is an anonymized version of that project-owned helper:

private static Guid StableId(Guid sourceId, string role)
{
    using var sha = SHA256.Create();
    var input = sourceId.ToString("D") + "/example-migration-v3/" + role;
    var hash = sha.ComputeHash(Encoding.UTF8.GetBytes(input));

    var identityBytes = new byte\[16];
    Array.Copy(hash, identityBytes, identityBytes.Length);
    return new Guid(identityBytes);
}

This needs the standard System.Security.Cryptography and System.Text namespaces. It is an identity convention, not an SDK requirement.

A role such as hero identifies one output of a page recipe. A globally shared disclaimer uses the disclaimer's source identity, so different pages can refer to the same generated item.

Keep the namespace and role strings stable after import. Changing them produces different IDs and needs a deliberate migration or cleanup plan.

Stable IDs also need validation. The project helper checked for collisions with incompatible target names, parents or templates instead of assuming that an existing ID meant the item was safe to reuse.

Preserve shared content without sharing page-specific numbering

Legal notes illustrated why a direct copy would have been misleading.

The source page selected shared disclaimers in a particular order. The target could reuse each disclaimer's content globally, but “footnote 1” was meaningful only within that page's ordered list.

The mapping therefore created two kinds of item:

  • A shared disclaimer, identified from the source disclaimer.
  • A local reference carrying its displayed number and a link to the shared item.

The list retained the source selection order. Another page could reuse the same disclaimer with a different number.

Field types mattered here too. Plain multiline legal text needed HTML encoding before it was written into a rich-text field. A content migration should not turn literal characters into unintended markup.

Rebuild presentation against the target component contracts

Once the data sources existed, the page needed an ordered rendering list.

A rendering definition identifies a component type. A rendering instance is one use of it on a page, with its own identity, data source, placeholder and parameters. Confusing those IDs makes nested composition particularly difficult to diagnose.

The project helpers assembled target presentation XML using reviewed rendering definitions and generated data-source IDs. They also validated target templates and field contracts before publishing the instruction output.

Global composition stayed with the target page design. The page recipe did not inject another copy of site-wide content that the design already supplied.

The detailed responsibilities were explicit: this entry wrote the page's design assignment and English final presentation. It left shared presentation alone. That choice was specific to the reviewed target design.

Leave unusual transformations visible

One source rich-text block combined a heading with body content. The project recipe split that known structure into target fields.

That was an explicit exception with a validation check. If an editorial change broke the expected source structure, generation stopped for review.

I would not turn that example into a universal HTML-splitting rule. A second page needs to demonstrate that the same assumption holds before the helper becomes a shared recipe.

The same applies to fallback composition. We discussed selecting registered recipes from source renderings when no explicit page plan existed, but that fallback was not implemented in the proof. A generic container ID alone did not tell us which target component it represented.

Review one complete page before scaling the pattern

The next review step was to apply the generated instructions in a lower environment and compare target preview with the intended page.

The useful questions went beyond item counts: did the hero use the right copy and link labels, did FAQs keep their order, did legal numbering still match the content, and did nested components appear in the correct placeholders?

Repeating generation should address the same item IDs. It should also be clear which older data sources remain unreferenced, because this entry did not automatically delete them.

From there, the scaling direction was a shared page runner, reusable component recipes and reviewable page plans. Moving hundreds of literal IDs from C# into JSON would make the code shorter, but it would not remove the underlying mapping work. Reuse comes from proving that the same transformation fits another page.

The value of this example is the path from a recognizable page to explicit, inspectable operations. V3 supplies the repository, field and instruction APIs. The project supplies the decisions about what the page should become.

The final post looks at the features that become useful as that work grows: multiple repositories, presentation transforms, media transfer and practical instruction delivery.

Authoring reference · V3 SDK