Skip to content

Pages

Template pages define which sections appear on each page of your storefront. Every page is a separate .ts file inside the pages/ directory of your template.

my-template/
├── configuration.ts
└── pages/
    ├── home.ts          # HOME page
    ├── product.ts       # PRODUCT storefront page
    ├── catalog.ts       # CATALOG storefront page
    ├── category.ts      # CATEGORY storefront page
    └── about.ts         # CUSTOM page
typescript
import { template, section } from '@lightspeed/crane-api';

export default template.page({
  sections: [
    section.default({
      id: 'slider',
      showcase_id: '001',
    }),
    section.custom({
      id: 'hero-banner',
      showcase_id: '1',
    }),
    section.custom({
      id: 'featured-products',
      showcase_id: '1',
    }),
  ],
});

Each page file must default-export the result of the template.page() factory from @lightspeed/crane-api. The file name determines the page type.

Page Types

The file name (without extension) maps to one of the built-in page types. Names that do not match a reserved name are treated as custom pages.

File namePage typeDescription
home.tsHOMEThe storefront home page
product.tsPRODUCTProduct detail pages (storefront page)
catalog.tsCATALOGThe product catalog page (storefront page)
category.tsCATEGORYCategory listing pages (storefront page)
Any other nameCUSTOMA custom page defined by your template

ℹ️ Storefront pages

PRODUCT, CATALOG, and CATEGORY are storefront pages. They have special constraints — see Validation Errors below.

Factory Functions

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

FactoryDescription
template.page()Creates a page configuration object with full type safety. Accepts sections and optionally metadata.
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.
section.store()Creates a storefront section placeholder. Sets type to 'store' 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 page configuration object has the following properties:

PropertyRequiredDescription
sectionsYesArray of sections displayed on this page
metadataConditionalRequired for CUSTOM pages, must be omitted for others

metadata

Only used on custom pages. Provides display information for the page.

PropertyRequiredDescription
titleYesDisplay title of the page (string)
Example — custom page with metadata — click to expand
typescript
import { template } from '@lightspeed/crane-api';

export default template.page({
  metadata: {
    title: 'About Us',
  },
  sections: [],
});

sections

An array of section objects. Each section must be one of three types: default, custom, or store.

Default Section

References a pre-defined Lightspeed section.

PropertyRequiredDescription
typeAutoSet automatically by section.default()
idYesMust match a default section name, optionally suffixed with _XXX where XXX is three digits (string)
showcase_idNoThree-digit showcase identifier (string)

The available default section IDs are:

IDDescription
headerSite header
footerSite footer
coverCover image / hero banner
announcement_barAnnouncement bar
sliderImage slider / carousel
special_offerSpecial offer / promotion
customer_reviewCustomer reviews
company_infoCompany information
shipping_paymentShipping and payment info
locationStore location / map
storeStore product listing
videoVideo embed
image_galleryImage gallery
contact_infoContact information
contacts_widget_whatsappWhatsApp contact widget
contacts_widget_instagramInstagram contact widget
contacts_widget_facebookFacebook contact widget
contacts_widget_phonePhone contact widget

To use multiple instances of the same default section, append _XXX (three digits) to the ID, e.g., slider_001, slider_002.

💡 Discoverability

Use your editor's autocompletion on the id field of section.default() to discover all valid values.

Custom Section

References one of your own section implementations.

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

Store Section

A placeholder for storefront-managed content. Used exclusively on storefront pages.

PropertyRequiredDescription
typeAutoSet automatically by section.store()
idNoOptional identifier (string)
Example — storefront page — click to expand
typescript
import { template, section } from '@lightspeed/crane-api';

export default template.page({
  sections: [
    section.store(),
  ],
});

Validation Errors

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

Storefront Page Errors

Storefront pages (PRODUCT, CATALOG, CATEGORY) follow strict rules: the sections array must contain exactly one section of type store.

ErrorCauseResolution
sections must contain at least one sectionsections array is empty on a storefront pageAdd a section.store() entry
Page type "..." must have exactly one sectionStorefront page has more than one sectionKeep only one section.store() entry
Page type "..." must have a section of type "store"Storefront page section is not of type storeReplace the section with section.store()

Non-Storefront Page Errors

Non-storefront pages (HOME, CUSTOM) cannot contain store sections and must not use 'header' or 'footer' as section ids (those belong in configuration.ts).

ErrorCauseResolution
Page type "..." cannot contain store sectionsNon-storefront page contains a store sectionRemove the store section or move it to a storefront page
Section "header" or "footer" is not allowed among page sectionsA section uses 'header' or 'footer' as its idMove header/footer sections to configuration.ts

Metadata Errors

CUSTOM pages must include a metadata property with a title. All other page types must not include metadata.

ErrorCauseResolution
Page type "CUSTOM" must have a metadata propertyCustom page is missing metadataAdd a metadata object with a title
Page type "..." must not have a metadata propertyNon-custom page includes metadataRemove the metadata property

Section Errors

ErrorCauseResolution
Custom section with id "..." must exist in sections directoryReferenced custom section not foundCreate the matching section in the sections/ 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 page objectRemove properties not defined in the schema

⚠️ Strict Mode

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

Next Steps