A Core dna site's repository holds the templates that render every page, the SCSS and JavaScript source, the built files the site serves, and a few static files; the platform supplies everything else. This guide covers that repository and the work around a page that is neither the template language nor the content model: building and serving assets, printing a record, styles and scripts, and the pages and signals that sit around the content.

Who this guide is for

Theme developers starting work in a repository, often one they did not create, and anyone reviewing a site's templates, styles or build before it goes live. It assumes you can read Smarty or Twig (Template languages: Smarty and Twig) and know how layouts and layout areas hold content (Input types, layouts, components and images). Every template example is given in both engines.

The units, in order

  1. Anatomy of a theme repo: what a repository holds and what it must not, the shapes you will inherit, the build and its output, and the house rules for scripts and asset URLs.
  2. Records in templates: what the controller hands a template, relations and links, custom fields, dates and money, escaping, and documenting a template's inputs.
  3. Stylesheets and SCSS: structure and naming, several stylesheets from one build, design tokens, Bootstrap, and critical CSS.
  4. Client-side code: entry files and modules, jQuery, TypeScript, dynamic imports, bundle budgets, icons and fonts.
  5. Around the main content: error templates, messages after a redirect, markup by environment, site data, failover pages, and what search engines are told.

Three rules that run through the guide

  1. Change the source, build, and commit both. The platform builds nothing, so the built files are committed with the source that produced them (Source and build output).
  2. Every script tag carries the nonce. Inline or external, each <script> gets the request's _inlineScriptNonce (The CSP nonce).
  3. Every asset URL changes with its file. Built files are cached for a year, so each URL carries the deploy hash (Cache-busting asset URLs).

Covered elsewhere