/sitecore-content-sdk:content-sdk-variants-vs-siblingsfrom Sitecore Content SDK - Core
Decides whether a new Sitecore presentation is a variant of an existing rendering or a sibling component. Covers FieldNames resolution, file conventions, and failure modes like MissingComponent.
Ships in Sitecore Content SDK - Core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When you need a new presentation in Sitecore, you have two options: extend an existing rendering with a new variant, or create a new sibling component (a fresh rendering). This skill says when to pick which, what's shared vs not, and exactly how the SDK resolves a variant at runtime.
<MissingComponent> or nothing.| Variant | Sibling component | |
|---|---|---|
| Sitecore rendering item | Same rendering, different FieldNames param | Different rendering item entirely |
componentName in layout response | Same | Different |
Rendering Contents Resolver | Shared (set on the rendering) | Each sibling can have its own |
Datasource Template | Shared | Each sibling can have its own |
Parameters Template | Shared | Each sibling can have its own |
Datasource Location query | Shared | Each can have its own |
ComponentQuery (Integrated GraphQL) | Shared | Each can have its own |
| Author swap cost in Pages | One dropdown click | Remove + add a different rendering |
| Headless Variant item required for author UI | Yes — one per variant | N/A |
| Head-app file convention | <Component>.<VariantName>.tsx, merged into one map entry | Separate folder per component, separate map entry |
Same data, different presentation. The author picks how this "Promo" should LOOK (Card, Hero, Minimal, Editorial) without changing what content they entered. One Sitecore concept, N visual treatments, swap with one click.
Variants only differ in head-side React representation. Everything else (resolver, templates, queries) is bound at the rendering level and is therefore shared across all variants of that rendering. There is no escape valve — if you need a per-variant resolver or per-variant params, you need siblings.
Anything that differs at the rendering level forces siblings. Concretely:
Rendering Contents Resolver GUID → siblings (e.g., the 4-resolver 2×2 family in content-sdk-resolver-patterns — Datasource Item / Datasource Children / Context Item / Context Children — must be siblings; their resolver classes differ).Datasource Template (different author-facing field set) → siblings.Parameters Template (different rendering params) → siblings.ComponentQuery (Integrated GraphQL) → siblings.Datasource Location constraint → siblings.Does the new presentation need any of:
- Different fields the author edits? → SIBLING
- Different rendering parameters? → SIBLING
- A different resolver / data shape? → SIBLING
- A different ComponentQuery? → SIBLING
Else (just a different look at the same data)?
→ VARIANT
A third option, beta only: a marketer-composed low-code component (atoms, content-sdk-app-router-atoms). The beta SDK reads lower-case fieldNames, so a Headless Variant authored in Sitecore (FieldNames) never selects a ComponentRef path.
src/components/Promo_Training/
Promo_Training.tsx # exports `Default` AND `export default Default`
Promo_Training.Fancy.tsx # exports `Fancy` AND `export default Fancy`
Promo_Training.Full.tsx # exports `Full` AND `export default Full`
Promo_Training.Minimal.tsx # exports `Minimal` AND `export default Minimal`
sitecore-tools project component generate-map produces:
import * as Promo_TrainingMinimal from 'src/components/Promo_Training/Promo_Training.Minimal';
import * as Promo_TrainingFull from 'src/components/Promo_Training/Promo_Training.Full';
import * as Promo_TrainingFancy from 'src/components/Promo_Training/Promo_Training.Fancy';
import * as Promo_Training from 'src/components/Promo_Training/Promo_Training';
['Promo_Training', { ...Promo_TrainingMinimal, ...Promo_TrainingFull, ...Promo_TrainingFancy, ...Promo_Training }]
All variant exports merge into one map entry keyed by componentName. The merged object carries:
Default, Fancy, Full, Minimal)default (the last-spread module's export default — i.e., the main Promo_Training.tsx)From @sitecore-content-sdk/react/dist/cjs/components/Placeholder/placeholder-utils.js:
const exportName = renderingDefinition.params?.FieldNames;
const renderedComponent =
exportName && exportName !== 'Default'
? component[exportName] // (A) named-export lookup
: component.default || component.Default || component; // (B) default fallback chain
if (!renderedComponent) {
logUnknownComponentError(...);
return <MissingComponent />;
}
FieldNames value | Path | What renders |
|---|---|---|
undefined / missing | (B) | component.default → component.Default → component |
"" (empty string) | (B) | Same as above (falsy) |
"Default" (literal) | (B) | Same as above — does NOT try component.Default via path A |
"Fancy" (exact, case-sensitive) | (A) | component.Fancy if it exists |
"fancy" (wrong case) | (A) | undefined → <MissingComponent> + console warning |
| Any value with no matching export | (A) | undefined → <MissingComponent> + console warning |
Three things to remember:
FieldNames value must match the export name exactly (Fancy ≠ fancy).FieldNames to the alphabetically first variant, before the head app sees it (§ Authoring side).<MissingComponent> placeholder + console warning.To make a variant available to authors via the Pages dropdown, you MUST create a Headless Variant item in the CMS:
/sitecore/content/<tenant>/<site>/Presentation/Headless Variants/<Rendering>/<VariantName>
Example: /sitecore/content/dog-feeding/training/Presentation/Headless Variants/Promo_Training/Fancy
.tsx files.Fancy) becomes the FieldNames value when the author selects it..tsx export, the dropdown still shows the variant but selecting it renders <MissingComponent>.The two sides must stay in sync. Adding a variant is a two-step operation: head-app .tsx file + CMS Headless Variant item. Either one alone is broken.
Pages writes these values for you. A script writing __Renderings XML over Authoring GraphQL has to get three things right, and a mistake in any of them silently renders the wrong variant:
FieldNames in s:par is the variant ITEM's GUID, braced and dashed: s:par="FieldNames={0A1B2C3D-4E5F-4A6B-8C7D-9E0F1A2B3C4D}". The Layout Service turns it into the item's name before it reaches the head app, so the SDK contract above is unchanged. A literal name (FieldNames=Light) resolved to the alphabetically first variant (Basic), with no error.Default Headless Variant item once any sibling variant exists, and reference its GUID. Without that item, an omitted FieldNames means "first child", not "Default". "Default" resolves only on a rendering with no variant items.key=value token (FieldNames={GUID}&HeadlineStyle=eyebrow). A save can also rewrite s:par as bare, valueless tokens (GridParameters&FieldNames&Styles&…), and one such placement resolved to a non-default variant. Remove bare tokens.After any raw placement write, read params back through the layout (content-sdk-debug-layout-probe, or a direct Edge layout query). The page builds, renders and passes review with the wrong variant, so reading params back is the only check that catches it.
FieldNames value === React export name, case-sensitive. No casing normalization, no fuzzy match..tsx export AND create Headless Variant item. Missing either side breaks one of two failure paths (no dropdown vs MissingComponent).componentName-based lookup will miss.<Component>.tsx) is spread LAST in gen-map output, so its export default wins as component.default. Keep the main file's default export as the "Default" variant for safe fallback behavior.FieldNames="Default" triggers the fallback chain, not a named lookup. Don't accidentally rely on component.Default being picked via path A — it's only picked via path B (as the second link after component.default).componentName matching the rendering item exactly (see content-sdk-component-naming-traps)..tsx without also creating the CMS Headless Variant item (or telling the user they need to). The variant will silently not appear in Pages..tsx export — production will render <MissingComponent> for that variant..sitecore/component-map.ts should have the variant's import alias added alongside the others, and they should all merge into the same componentName map entry.FieldNames to the variant name in Pages → the head app should render the variant's component.FieldNames to a deliberately wrong name → the head app should render <MissingComponent> and log a warning to console (proves the resolution flow is wired right).FieldNames entirely → the head app should render the default variant (the main file's export). On a rendering with Headless Variant items, assert that the resolved params.FieldNames is Default and not the first variant alphabetically.content-sdk-app-router-component-scaffold — for the underlying file-structure rules.content-sdk-app-router-component-variants — generic SDK guidance on variants; this skill is the playground-derived, runtime-verified deep dive.content-sdk-component-naming-traps — folder/file naming for components AND variants.content-sdk-resolver-patterns — the resolver-level distinctions that often force sibling vs variant choices.@sitecore-content-sdk/react/dist/cjs/components/Placeholder/placeholder-utils.js (function that resolves FieldNames to an export).DEFAULT_EXPORT_NAME constant: @sitecore-content-sdk/react/dist/cjs/components/sharedTypes/components.js = "Default".Promo component with four variants (Default, Fancy, Full, Minimal) and the four matching Headless Variant items under the site's Presentation/Headless Variants/Promo/; the file convention and the resolution behaviour above are transcribed from that run.What SKILL.md sets; muted values are Claude Code's defaults
23 skills in this plugin
/content-sdk-analytics-eventsSends Content SDK analytics events: analytics and events plugins, pageView, event, form, identity, field limits, client vs server, bot and editing suppression. Use when adding or debugging tracking calls. Not consent or personalization./content-sdk-atomic-design-assessmentAssesses a Content SDK head app for Atomic Design: scan src/components, rate each low-code candidate / partial / keep-code, derive the atom set, plan a side-by-side migration. Use when asked which components could become atoms. Not writing atoms./content-sdk-npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-content-sdkOther plugins' skills for the same job