Who this is for. Every developer who writes templates for a server-rendered or hybrid Core dna site, whichever engine it uses, and the technical lead choosing an engine for a new one. It assumes you have been through Core dna for site builders, so you know what a record, a layout and a component are, and that you have read some template code before. It does not assume you know Smarty or Twig.

Why one guide for both

A site's engine is a single setting, and the choice changes less than people expect. Routing, layouts, areas, components, the variables a template receives, what it may call on a record, caching and every module's behaviour are the same in both. What differs is the syntax, the helpers the platform registers, and the security model: Smarty runs under a list of allowed PHP functions, Twig without a sandbox, and neither escapes output unless asked. This guide states the shared parts once, then gives each engine the same depth, so that no developer has to reconstruct their engine's surface from someone else's templates.

Every template example elsewhere on this site is shown in both engines. In this guide, the Smarty and Twig units show one engine each, by design.

The order to read it in

  1. The shared model, for everyone: how a template is found and chosen for a record, what it receives, what it may call, template code kept in the admin, compilation, and how to choose an engine.
  2. Smarty or Twig, for your site's engine: the language as you write it here, composition, the platform's additions, and the security position.
  3. Comparing and porting, when you read or review the other engine, or move a site between them.
  4. Translation and internationalisation, before the first label of a multi-language site.

Not sure which engine a site uses? Tell whether a site is Smarty or Twig in thirty seconds.