# Templates & Global Surfaces

How a theme seeds each page's starting composition, which surfaces are global (header, footer, overlay), and how per-template overrides of globals work.

A section defines WHAT can render; a template defines what a page STARTS as. Each templates/<page_type>.json file in the bundle is an ordered list of section instances — type, position, settings, and (for block-capable sections) explicit starting blocks with stable ids you choose.

```json
{
  "page_type": "home",
  "sections": [
    { "type": "hero", "position": 1, "settings": {} },
    { "type": "featured-products", "position": 2, "settings": {} },
    { "type": "marquee", "position": 3, "settings": {
        "blocks": [
          {"id": "home-marquee__block_0", "type": "word", "settings": {}}
        ]
    }}
  ]
}
```

> SEEDING LAW: installs materialize compositions from the bundle's TEMPLATE files — not from schema block defaults. A section's "blocks": {"default": […]} applies only when a merchant ADDS that section in the editor. If your header or footer must ship with a block, that block must be listed in the global surface template — adding a new default block type in a later version does not appear on installed stores unless the template seeds it.

Empty settings ({}) are correct in templates: schema setting defaults materialize per-section at install. Set explicit values only where the template's composition differs from the schema default.

## Page types

## Alternate templates

A theme can ship more than one look for the same surface. Name the file <surface>__<name>.json — page__contact.json, product__preorder.json — and give it a name in the JSON ("name": "Contact"); that name is what merchants see in the template picker. The composition inside is ordinary: any sections the surface allows, in any order.

```json
// templates/page__contact.json — the base page plus a contact form
{
  "page_type": "page__contact",
  "name": "Contact",
  "sections": [
    { "type": "content-page", "position": 0, "settings": {} },
    { "type": "contact", "position": 1, "settings": {} }
  ]
}
```

Merchants assign templates per resource: a Page, a product, or a blog post carries a template handle, chosen in its admin form. A resource with no handle renders the base template. If the active theme has no template matching a resource's handle — a theme switch, say — the platform falls back to the base template explicitly, so a configured page never renders blank.

This is how contact pages work end to end: the merchant writes an ordinary Page, assigns the Contact template, and the template's contact section carries the contact_submit form. Nothing about contact is a special page type — the Page provides the words, the template provides the form.

Standard surface keys: home, shop, product, collection, collection_list, category, category_list, page, policy, blog, blog_list, blog_category, blog_tag, blog_author, metaobject, metaobject_list, vendor, vendor_list, brand, brand_list, search, cart, wishlist, track_order, gift_card, account, login, register, not_found, coming_soon, maintenance, and password. The three editable global surfaces are listed below. Alternate templates use the double-underscore suffix, such as product__summer. gift_card is the platform's Gift Card page (/gift-cards and the View your gift card link): every theme ships a non-empty templates/gift_card.json holding the section its gift_card surface entry requires. See [Gift Cards in your theme](/themes/gift-cards) for what to build and [Gift Card products and purchases](/ctx/gift-card-products) for its data. blog_tag is a blog tag page ({blog list}/tagged/{tag slug}) and blog_author an author archive ({blog list}/authors/{author slug}): each renders with templates/blog_tag.json (templates/blog_author.json) when the theme has one, else with templates/blog_list.json. Both read ctx.blog for the page's posts and ctx.blog_tag (ctx.blog_author) for the tag (author); see [Blog](/ctx/reference-content). A new Theme Store version must ship a non-empty template for every standard surface, these four included (`themecheck --mode sealed`); a version published before blog_tag, blog_author, metaobject and metaobject_list joined that list still installs and updates, and its pages render with the fallback.

## Global surfaces

Three editable global surfaces render around page templates: global_body_start, global_body_end, and global_overlay. Their compositions are edited once and apply across the storefront. global_head and global_compliance_head are reserved platform surfaces and cannot be declared in a theme package.

| Surface | Renders | Typical sections |
| --- | --- | --- |
| global_body_start | Opening of <body>, before the page template | announcement bar, header |
| global_body_end | End of <body>, after the page template | footer |
| global_overlay | Overlay layer rendered with the storefront | cart drawer, localization prompt, popups |

## Layout choices

A surface can offer interchangeable layouts of one part: list them as a group in theme.json's `required_one_of` for that surface, for example `"required_one_of": [["header", "header-mega", "header-tabs"]]` on global_body_start. Each group holds exactly one of its sections at a time, and the editor's Change layout picker swaps it for another member, showing each section's `preview_image` (a theme asset such as assets/header-mega.png) when it declares one.

A swap keeps the merchant's content. The section keeps its id, position, visibility and custom style. A setting the new layout declares with the same id and type keeps its value when the value is valid for the new definition (its options, range and length); a block whose type the new layout takes keeps its id, state and valid settings, in the merchant's order, up to the new layout's blocks.max; theme and app blocks keep their own settings. Customer-group versions carry the same way, and translations follow, since they are keyed by section and block ids. Settings the old layout lacked start at their defaults, and the new layout's default blocks of types the old layout could not hold are added where its blocks.default places them. Everything else is dropped, and the editor's undo brings it back, as for any edit. Swapping back carries back whatever both layouts share.

> Give the layouts of one group the same ids and types for what they share (menu, logo, links, sign-up text, social links) and the same block types for shared blocks, so a merchant who changes layout keeps their content.

## Per-template overrides of a global

Editing a global section from the Global Sections view changes it EVERYWHERE. Editing the same section while a specific template is open materializes a per-template OVERRIDE: that template gets its own copy; every other page keeps the theme default. Resetting the override deletes the copy and the template falls back to inheriting the global again. Themes do not declare any of this — it is platform behavior over the same sections.

Visibility is the template's lever, not duplication: a template can hide a global section (disabled on the override) rather than shipping a second variant of it. One footer, overridden where a landing page needs it quieter — never two footer sections.

## Gate surfaces

`coming_soon`, `password`, and `maintenance` need their own templates and required-section policies. They do not inherit the store’s body chrome; scoped surface overrides can add it explicitly. Required gate sections render platform-provided `settings.title` and `settings.message` for translated copy. Maintenance is a public HTTP 503 response with Retry-After. See [Gate pages](/themes/gate-pages) for composition, form outcomes, staff previews and detecting when maintenance ends.

