Skip to content

Configuration

Every template requires a configuration.ts file at its root. This file defines the template's metadata, page chrome (header and footer), and can define optional global visual defaults (colors, fonts, alignment, page layout, and corner radius).

Full example

typescript
import { template, section } from '@lightspeed/crane-api';

export default template.configuration({
  metadata: {
    name: 'My Store Template',
    description: 'A modern template designed for apparel and footwear stores',
    categories: ['apparel_footwear', 'sport_outdoor'],
    preview_url: 'https://my-store-template.company.site',
    cover_image: {
      set: {
        ORIGINAL: {
          url: 'cover_image.jpg',
          width: 1200,
          height: 800,
        },
      },
    },
  },
  header: section.custom({
    id: 'my-custom-header',
    showcase_id: '001',
  }),
  footer: section.default({
    id: 'footer',
  }),
  styleId: 'customName-001',
  globalSettings: {
    colorPalette: {
      colorA: '#111111',
      colorB: '#FFFFFF',
      colorC: '#F5F5F5',
      colorD: '#D9D9D9',
      colorE: '#666666',
      colorF: '#FF5A00',
    },
    fonts: {
      fontPair: {
        headingFont: 'inter',
        headingFontStyle: 'bold',
        bodyFont: 'roboto',
        bodyFontStyle: 'regular',
      },
      general: {
        heading1: { fontSize: 48 },
        heading2: { fontSize: 40 },
        heading3: { fontSize: 32 },
        heading4: { fontSize: 24 },
        body1: { fontSize: 20 },
        body2: { fontSize: 18 },
        body3: { fontSize: 16 },
        body4: { fontSize: 14 },
      },
    },
    alignment: 'center',
    pageLayout: {
      contentWidth: 1128,
    },
    cornerRadius: 'sharp',
  },
});

The configuration file must default-export the result of the template.configuration() factory from @lightspeed/crane-api.

Factory Functions

The @lightspeed/crane-api package exports the following factory functions used in configuration files:

FactoryDescription
template.configuration()Creates a template configuration object with full type safety. Accepts required metadata, header, and footer, plus optional all-or-none styleId and globalSettings.
section.default()Creates a default section referencing a pre-defined Lightspeed section. Sets type to 'default' automatically.
section.custom()Creates a custom section referencing your own section implementation. Sets type to 'custom' automatically.

💡 Recommended

Using factory functions is recommended over plain objects. They provide type safety and automatically set the type discriminator field for you.

Properties

The configuration object has three required top-level properties. Style settings are optional, but if you use them, provide both styleId and a complete globalSettings object. Delete both properties when the template does not define style settings; do not leave globalSettings: {} in configuration.ts.

PropertyRequiredDescription
metadataYesDisplay information shown to store owners
headerYesHeader section for all pages in the template
footerYesFooter section for all pages in the template
styleIdNoStyle identifier for the template's theme. Required when globalSettings is provided. Generated templates set this to customName-001
globalSettingsNoGlobal design defaults for colors, typography, layout, and shape. Required when styleId is provided

metadata

The metadata object describes how your template appears in the Lightspeed template gallery.

PropertyRequiredDescription
nameYesDisplay name of the template (2–60 characters)
descriptionYesShort description of the template (2–150 characters)
cover_imageYesCover image shown in the template gallery (object)
preview_urlNoURL where the template can be previewed live
categoriesNoArray of unique category tags for the template

metadata.cover_image

An object with a required set property and an optional borderInfo property.

PropertyRequiredDescription
setYesObject containing one or more image variants
borderInfoNoBorder metadata for the image (object)

The set object must contain at least one image variant. Available variants:

VariantRequiredDescription
ORIGINALNoOriginal full-size image (object)
WEBP_LOW_RESNoLow-resolution WebP for desktop (object)
WEBP_HI_2X_RESNoHigh-resolution 2x WebP for desktop (object)
MOBILE_WEBP_LOW_RESNoLow-resolution WebP for mobile (object)
MOBILE_WEBP_HI_RESNoHigh-resolution WebP for mobile (object)

ℹ️ Note

At least one variant must be present in the set object. Typically you provide ORIGINAL at a minimum.

Each image variant object has:

PropertyRequiredDescription
urlYesPath or URL to the image file (string)
widthNoImage width in pixels (non-negative integer)
heightNoImage height in pixels (non-negative integer)

metadata.preview_url

When provided, the preview URL must be a valid URL on an allowed domain. Invalid domains will be rejected during validation.

metadata.categories

An optional array of unique category tags.

💡 Discoverability

The available category values are defined in the factory types. Use your editor's autocompletion on the categories array to discover all valid values.

The header section applied to every page in the template. Can be a default section or a custom section.

Default Header Section

PropertyRequiredDescription
typeAutoSet automatically by section.default()
idYesMust be 'header' or match the pattern header_XXX where XXX is three digits
showcase_idNoThree-digit showcase identifier (string)

Custom Header Section

PropertyRequiredDescription
typeAutoSet automatically by section.custom()
idYesIdentifier for your custom header section (string)
showcase_idNoShowcase identifier (string)
showcase_overridesNoOverride showcase content and design values (object)
categoryNoCategory for collection sections (string)

The footer section applied to every page in the template. Accepts the same structure as header.

PropertyRequiredDescription
typeAutoSet automatically by section.default()
idYesMust be 'footer' or match the pattern footer_XXX where XXX is three digits
showcase_idNoThree-digit showcase identifier (string)
PropertyRequiredDescription
typeAutoSet automatically by section.custom()
idYesIdentifier for your custom footer section (string)
showcase_idNoShowcase identifier (string)
showcase_overridesNoOverride showcase content and design values (object)
categoryNoCategory for collection sections (string)

styleId

The optional style identifier for the template's theme. Generated templates set it to customName-001. If you provide styleId, you must also provide a complete globalSettings object.

globalSettings

Optionally defines global design values that can be reused by template pages and sections. If the template does not need style settings, delete the globalSettings object from configuration.ts instead of leaving it empty.

PropertyRequiredDescription
colorPaletteYesSix-color global palette (colorA-colorF)
fontsYesTypography system (font pair + font sizes)
alignmentYesDefault content alignment. One of: left, center
pageLayoutYesDefault page layout settings
cornerRadiusYesRequired default corner radius token

globalSettings.colorPalette

colorPalette must contain exactly six hex colors.

PropertyRequiredDescription
colorAYesHex color, e.g. #111111
colorBYesHex color, e.g. #FFFFFF
colorCYesHex color
colorDYesHex color
colorEYesHex color
colorFYesHex color

globalSettings.fonts

fonts contains a base font pair and default sizes for typography tokens.

PropertyRequiredDescription
fontPairYesBase heading/body font family and style
generalYesDefault font sizes for heading1-heading4 and body1-body4
globalSettings.fonts.fontPair
PropertyRequiredDescription
headingFontYesFont family. Allowed values are validated by Crane's built-in font enum lists (system, Google, and custom set).
headingFontStyleYesOne of: regular, medium, semibold, bold, regular-italic, medium-italic, semibold-italic, bold-italic
bodyFontYesFont family. Same allowed set as headingFont
bodyFontStyleYesOne of: regular, medium, semibold, bold, regular-italic, medium-italic, semibold-italic, bold-italic
globalSettings.fonts.general

Each token (heading1, heading2, heading3, heading4, body1, body2, body3, body4) requires a fontSize value.

Allowed fontSize values are:

12, 14, 16, 18, 20, 24, 32, 36, 40, 48, 56, 64, 80, 96, 112.

globalSettings.alignment

Required default alignment for theme content when globalSettings is provided. Allowed values are left and center.

globalSettings.pageLayout

Required default page layout settings when globalSettings is provided.

PropertyRequiredDescription
contentWidthYesContent width as an integer, e.g. 1128

globalSettings.cornerRadius

Required default corner radius token. Allowed values are:

sharp, softened, slightly_rounded, rounded, greatly_rounded.

WARNING

globalSettings is optional as a whole. However, if you keep it in configuration.ts, all of its fields are mandatory. globalSettings: {} and partially filled style settings fail validation during crane build.

Validation Errors

Crane validates your configuration.ts during the build step. Below are the errors you may encounter and how to resolve them.

Metadata Errors

ErrorCauseResolution
name must be at least 2 charactersname is too shortProvide a name with at least 2 characters
name must be at most 60 charactersname is too longShorten the name to 60 characters or fewer
description must be at least 2 charactersdescription is too shortProvide a description with at least 2 characters
description must be at most 150 charactersdescription is too longShorten the description to 150 characters or fewer
preview_url must be a valid URLInvalid URL formatUse a valid URL starting with http:// or https://
preview_url must match pattern ...URL is not on an allowed domainUse an allowed domain for the preview URL
categories must contain unique itemsDuplicate values in categoriesRemove duplicate category entries

Style Settings Errors

ErrorCauseResolution
globalSettings is required when styleId is providedstyleId is set without globalSettingsAdd a complete globalSettings object or remove styleId
styleId is required when globalSettings is providedglobalSettings is set without styleIdAdd styleId or remove globalSettings
Required field errors under globalSettingsglobalSettings is empty or incompleteFill all style fields or delete globalSettings from the config

Image Errors

ErrorCauseResolution
set must have at least one propertycover_image.set is emptyAdd at least one image variant (e.g. ORIGINAL)
must be a non-negative integerNegative width or height valueUse a non-negative integer for image dimensions

Section Errors

ErrorCauseResolution
Header section must have id "header" when type is "default"Default header has a non-matching idSet id to 'header' or use the header_XXX pattern
Footer section must have id "footer" when type is "default"Default footer has a non-matching idSet id to 'footer' or use the footer_XXX pattern
Custom header section with id "..." must exist in headers directoryReferenced custom header not foundCreate the matching section in the headers/ directory
Custom footer section with id "..." must exist in footers directoryReferenced custom footer not foundCreate the matching section in the footers/ directory
id must match pattern: [default_section_name] or [default_section_name]_XXXDefault section id doesn't follow the naming conventionUse a valid default section name, optionally suffixed with _ and three digits
showcase_id must be a three digit stringshowcase_id is not three digitsUse a three-digit string like '001'

Schema Errors

ErrorCauseResolution
Unrecognized key(s) in objectExtra properties in the configurationRemove properties not defined in the schema

Global Settings Errors

ErrorCauseResolution
Invalid enum valueUnsupported headingFontStyle / bodyFontStyleUse one of regular, medium, semibold, bold, regular-italic, medium-italic, semibold-italic, bold-italic
Invalid inputUnsupported font family nameUse a font value from Crane's supported font lists
Invalid input: expected one of ...Unsupported fontSize valueUse one of the allowed font size tokens listed in this guide
must be a valid hex color / Invalid stringInvalid colorPalette hex valueUse valid hex color format, for example #1A1A1A
Invalid option / Invalid inputUnsupported alignment or cornerRadius valueUse one of the documented theme values
Invalid input: expected intpageLayout.contentWidth is not an integerUse an integer content width, for example 1128

⚠️ Strict Mode

The configuration schema uses strict mode. Only documented properties are allowed — any extra fields will cause a validation error.

Next Steps