Skip to content

Configuration

Every template requires a configuration.ts file at its root. This file defines the template's metadata and page chrome (header and footer).

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',
  }),
});

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 metadata, header, and footer properties.
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 top-level properties, all required:

PropertyRequiredDescription
metadataYesDisplay information shown to store owners
headerYesHeader section for all pages in the template
footerYesFooter section for all pages in the template

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)

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

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

⚠️ Strict Mode

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

Next Steps