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
- 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.
- Records in templates: what the controller hands a template, relations and links, custom fields, dates and money, escaping, and documenting a template's inputs.
- Stylesheets and SCSS: structure and naming, several stylesheets from one build, design tokens, Bootstrap, and critical CSS.
- Client-side code: entry files and modules, jQuery, TypeScript, dynamic imports, bundle budgets, icons and fonts.
- 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
- 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).
- Every script tag carries the nonce. Inline or external, each
<script>gets the request's_inlineScriptNonce(The CSP nonce). - 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
- How the platform finds a template, and overriding its own: Template resolution order.
- Reading layout areas: The area getters and what each costs.
- Layouts, components and images: The chain from input type to template and Images end to end.
- Translating in templates and choosing the language: Translation and internationalisation.