FeaturesTemplates & Design

Your markup stays yours, in plain Twig files

Total CMS renders with Twig, and the whole CMS is reachable from a template through a single global variable. You write the HTML; the CMS hands you the content.

Standard Included in Standard and Pro

The Twig Playground running cms.collection.objects('blog'), sorted by date and sliced to three, with the rendered journal posts shown below the code.
The Twig Playground running cms.collection.objects('blog'), sorted by date and sliced to three, with the rendered journal posts shown below the code.

Total CMS renders with Twig 3, in template files you own and keep in your own repository, with automatic output escaping and compiled caching so the parsing happens once. There is no PHP to write, which is rather the point: a designer can work in a template without first learning the framework underneath it.

One cms global

Organised into namespaces, each with its own reference page:

  • Collections. cms.collection.*: objects, searching, URLs, navigation.
  • Fields. cms.data.*: typed access to a single field.
  • Media. cms.media.* and cms.render.*: image paths, galleries, downloads, streaming, pagination markup.
  • The rest. cms.feed.*, cms.seo.*, cms.auth.*, cms.schema.*, cms.builder.*, cms.locale.*, cms.view.*, cms.qrcode.* and cms.barcode.*.

Filters and tags added to Twig's own

  • Filters. Text through markdown, truncate, nl2br or title; dates through date or dateRelative; colours through oklch, rgb, hsl and hex.
  • Tags. cmsgrid renders a collection into a grid, list or compact layout; the cache tag stores the rendered HTML of anything expensive.
  • Logging. cms.log() writes from the template into the admin's log analyzer, for when something is missing.

Two helpers in every layout

cms.assetsHead() goes in the head and cms.assetsBody() just before the closing body tag.

  • What they emit. The stylesheets and scripts Total CMS's own output depends on (grid layout, galleries, pagination, icons, HTMX) plus anything an extension registered.
  • Why not to skip them. Leave them out and nothing errors: the grid renders as an unstyled stack and the lightbox never opens, which is a good deal harder to debug than an error.

A real blog index is a for-loop over cms.collection.objects('blog'), each Markdown body run through the markdown filter, and the listing wrapped in a cache tag tagged with the collection so it rebuilds the moment an editor publishes.

In practice

What it looks like in a template

twig
{% set posts = cms.collection.objects('blog') %}

{% for post in posts %}
	<article>
		<h2>{{ post.title }}</h2>
		<time>{{ post.date | date('F j, Y') }}</time>
		<div class="content">{{ post.content | markdown }}</div>
	</article>
{% endfor %}

Read a collection, loop it, and run a Markdown field through the markdown filter — the same three moves work for every collection on the site.

At a glance

What you get

One cms global
Collections, media, feeds, SEO, auth, schemas and Site Builder all hang off the same variable, split into namespaces. There is one thing to learn, not twenty.
Escaped by default
Twig escapes output automatically, so a field full of angle brackets cannot quietly become markup on your page.
Compiled and cached
Total CMS caches compiled templates, so the parsing cost is paid once. The admin's Cache Manager clears it after a large change.
Grids without the CSS
The cmsgrid tag lays a collection out as a grid, a list, or a compact row, with helper classes your own stylesheet can override.
Core assets in two calls
cms.assetsHead() and cms.assetsBody() emit everything the CMS output needs, in the right order, cache-busted, including extension assets.

Twig templating

Common questions

Do I need to know PHP?

No. Twig is its own template language, designed to be readable and writable without PHP knowledge. Everything the CMS exposes is reachable through the cms variable.

What do the asset helpers actually emit?

The core stylesheets and scripts the CMS's own output depends on — grid CSS, gallery CSS and JS, pagination CSS, content and icon styles, and HTMX — plus any assets registered by extensions. Without them Load More never fetches and galleries never lay out.

Where do templates live?

Templates are managed in the admin at /admin/templates. A template id can contain forward slashes to organise into folders, and the .twig extension is added for you.

Can I debug a template?

Turn on debug mode and dump() is available inside templates. cms.log() writes a message, level and context into twig.log, which the admin log analyzer reads.

Try it on a site of your own.

45 days, every Pro feature, no credit card. Build it, hand it to a client, and see what they can and can’t touch.