Variants and presets
Variants let you offer alternative defaults—different margins, paper sizes, or feature toggles—without duplicating the entire template. They live inside configuration.sfo.yml as separate YAML documents using kind: Variant.
About Variants
Variants are currently not yet implemented in the reference editor implementation.
Anatomy of a variant
A variant block contains metadata for the UI and a list of patches that adjust existing components. The two sample templates demonstrate different use cases:
- The journal templates ship without variants by default, keeping the configuration straightforward for article workflows.
- The monograph template defines two variants (
A5andengineering) grouped underpage-sizes, showing how to adapt page dimensions and inject faculty-specific CSS without cloning the whole template.
kind: Variant
metadata:
title: Thesis (online)
description: Optimised for single-sided printing and web-sized images.
spec:
patches:
- type: default
target:
kind: Page
patch:
- op: replace
path: /properties/page/properties/handling/default
value: single-sided
- type: conf
target:
kind: Environment
patch:
- op: replace
path: /spec/transformImages/dpi
value: 96
Key ideas:
type: defaultchanges the JSON Schema defaults shipped with a component. Use this when you want the editor to show different starting values. (SeepatchDefaultinlibs/export/src/html/components/variant/variant.schema.ts.)type: confoverwrites the configuration values saved in the YAML file without touching the schema defaults. (SeepatchConfin the same schema.)- Each
patchentry is a standard JSON Patch operation. Paths point to keys within the component schema. When targeting defaults you must end the path in/default; when updating saved configuration values start the path with/spec. target.kindpicks which component to adjust. Combine it withtarget.metadata.nameif the same component appears multiple times.
Monograph example
TheA5variant updates thePagedefaults (size, margins, font size) and then narrows multiple header/footer variants by matchingmetadata.name(for-front,for-body,for-back). This approach keeps front/back matter aligned without duplicating assets.
Grouping and exposing variants
The main Configuration block can add extra structure so the editor presents variants clearly:
variantGroups(seeConfigurationConfigurationinlibs/export/src/html/components/configuration/configuration.schema.ts) prevent contradictory variants from being selected together. Use them for mutually exclusive layouts such as “Single sided” vs “Double sided”.subTemplatesbundle a list of variant names into a ready-made preset. The order of names invariantOrdermatters because patches apply sequentially.
Monograph templates usually expose a single variant group (page sizes) with clear titles so faculty administrators can pick the correct preset. Journals tend to leave variants turned off unless there is a compelling set of alternate defaults.
When to create a new template instead
Variants are ideal when 90% of the layout stays the same. If you find yourself rewriting large parts of the component list or shipping vastly different assets, fork the template instead. Keeping variants focused avoids confusion for less technical users and simplifies maintenance.
Variant testing checklist
- Apply the variant locally (or via the API) and export every supported format—PrinceXML, HTML, EPUB, etc.
- Disable the variant and repeat the exports to ensure defaults still work.
- For monographs with multiple header/footer components, verify that page counters and translations remain correct after patches run.
- Update the template
readmewith a short description of each variant so editors know when to use them.