Skip to content

Styles and templates

How a rendered page gets its shell and CSS, and where static page HTML comes from. All of this is read-side on the worker-facing /settings bundle.

Post–AISD-218 model

Template markup and stylesheets are not MySQL LONGTEXT. They live in the per-env cms-templates S3 bucket. The DB holds thin registries (templates, styles) plus curated template_styles pairings. The old three-layer chain (template_elements → template_blocks → site_block_overrides) and sites.template_id / sites.style_id are gone.

Presentation selection: template_style_id

A site picks one pairing — not a free mix of template and style:

  1. EAV key site_settings.template_style_id (int) points at template_styles.id.
  2. cms-api loads that active pairing → (template_id, style_id).
  3. Public /settings exposes:
  4. active_template: {id, slug, version, ...}
  5. active_style: {id, slug, version, critical_css} (critical_css is the style's above-the-fold CSS for the worker to inline; "" when none is built)

Missing or inactive pairing → HTTP 424 template_style_not_configured (no soft default to an arbitrary style).

Admin write: PATCH /admin/v1/sites/{site_id}/template-style with {"template_style_id": <int>}. Prefer this over any legacy style-only path.

Resolution lives in the public store (SqlPublicStore / MemoryPublicStore) when building the settings bundle.

Where the bytes live (S3)

Registry Typical s3_key Public fetch
templates templates/<slug>/<version>/shell.html GET /public/v2/templates/{slug}/shell
styles styles/<slug>/<version>.css GET /public/v2/styles/{slug}/css (worker proxies under /_assets/styles/...)

s3_key is bucket-relative; the environment selects the bucket (cms-templates-{env}-…). See hq/infrastructure/s3/cms_templates/README.md.

Operator workflow

  1. Edit the git mirror under cms-cf-worker/templates/ (styles or shell).
  2. Upload via admin file API: POST /admin/v1/styles/{id}/file or POST /admin/v1/templates/{id}/file — stamps s3_key + version.
  3. Purge the worker cache / settings so HTML picks up the new <link> or shell (see cms-cf-worker caching / deploy docs).

Do not store CSS or shell HTML in the database.

Static pages (AISD-227)

About, contact, privacy, terms, and do-not-sell bodies are site settings, not template-block rows:

Setting key Typical route
about_html /about
contact_us_html /contact-us
privacy_policy_html privacy
terms_of_use_html terms
do_not_sell_html do-not-sell

They appear on the merged /settings payload. The worker prefers these keys and may fall back to a shell slot when a setting is empty.

The /settings templates map is empty (AISD-218): _resolved_templates_map no longer walks an override chain.

Default / reserved ids

Reserved registry rows (e.g. historical id=-1 style/template) may still exist for bootstrap, but site selection is always via template_style_id, not by writing sites.style_id / sites.template_id (those columns were dropped in AISD-226). See Default preset.