A theme is a set of templates that tell the CMS how to turn stored content into HTML. The CMS picks a template for each request, fills it with data and sends the result. Keeping content apart from presentation lets you redesign a site without rewriting a single article.
Every CMS that builds pages for readers needs a way to combine stored content with page markup. That layer is called a theme, a template set or a skin, depending on the product. Understanding how it works tells you what a redesign will cost, who can make changes, and where the traps are. This guide covers the architecture. For choosing and customising a ready-made design, see our thread on themes.
What does a theme do?
When a reader requests a page, the CMS works out what is being asked for, fetches the relevant content, and hands both to the templates. The templates return HTML. A theme is the set of templates, along with stylesheets, scripts and images, that controls the output.
The central design idea is the separation of content from presentation. An article is stored as fields: headline, body, author, date, section. The theme decides where each field goes on the page. That is why the same story can appear in a full article layout, a compact list on a section front and a feed item, with no re-entry.
For a publisher this separation has three practical benefits:
- Redesigns do not touch the archive. You change the theme, not ten thousand articles.
- Consistency is enforced. Every article uses the same template, so layout does not depend on who wrote the story.
- Roles stay apart. Editors work with fields, developers work with templates.
The separation is never perfect. Formatting inside the body field, embedded widgets and shortcodes can tie content to a particular theme. See organising content for the structural side.
How does a CMS choose which template to use?
Most systems have a lookup order, so that a specific template overrides a general one. WordPress documents this as the template hierarchy. Its developer documentation describes the hierarchy as the way WordPress decides which template file to use for a page, searching down until it finds a match.
WordPress follows three steps: it matches the query to a page type, selects templates according to the hierarchy order, and uses the first matching template file in the theme directory. If nothing more specific matches, the documentation says the theme’s index.php file will be used.
A category page shows the pattern clearly. WordPress developer documentation gives this order:
| Priority | File | Use |
|---|---|---|
| 1 | category-{slug}.php | One named category, such as category-news.php |
| 2 | category-{id}.php | One category by its numeric ID |
| 3 | category.php | All category pages |
| 4 | archive.php | Any archive page |
| 5 | index.php | The final fallback |
The practical lesson holds for other systems too. A site can start with one general template, then add specific ones where a section needs a different layout, such as a distinct look for opinion or a sports front. If you plan sections like this, ask the vendor how its lookup order works. Our guide to organising content explains why section structure and template choice are linked.
What template languages do CMSs use?
A template language is the syntax inside a template file that inserts content and handles simple logic such as loops and conditions. Three approaches appear in the documentation we checked.
Plain PHP
WordPress themes are built from PHP template files, as the category example above shows. That gives developers full power, including the power to put heavy logic in the template. It also means a template can do things a designer should not.
Twig
Twig is a template engine for PHP. Drupal’s documentation says its Twig templates use the .html.twig extension and that separating template logic from PHP code provides a more secure environment. The same documentation says developers can override all templates used for HTML markup.
Craft CMS also uses Twig. Its documentation describes Twig as a fast and powerful templating system commonly used for front-end views in content management systems like Craft, Drupal and WordPress, and says Twig code is marked with the delimiters {# #}, {% %} and {{ }}. For a developer, skills transfer between these systems more than you might expect.
Handlebars
Ghost’s documentation says its themes use the Handlebars templating language, which creates a strong separation between templates (the HTML) and any JavaScript logic with the use of helpers. The trade-off is that a deliberately limited language cannot do everything. Complex logic must live in helpers or outside the template.
Why does the choice of language matter to a publisher?
You will rarely write templates yourself, but the language affects who you can hire and how much a change costs.
- Developer supply. A widely used language means more people can maintain your theme.
- Safety. A language that limits what templates can do reduces what a mistake can break.
- Portability. Templates are tied to the system, so a theme cannot move to another CMS. Moving means rebuilding.
- Speed of change. A limited, clear language makes small changes quick.
What happens when a theme is updated?
Themes from third parties receive updates, and an update can overwrite local changes. The usual defence is to keep your changes separate from the original files, using whatever override mechanism the system provides. Drupal’s ability to override templates is one example. Check your system’s documentation before editing a vendor theme directly.
Treat theme updates as you would any extension. Try them on a staging copy, check the article page, section page and home page, and keep a backup. The same cautions apply as in how plugins work.
How do themes affect speed and accessibility?
Templates decide the HTML that readers receive. That means a theme can quietly harm page speed, heading structure, image text alternatives and keyboard navigation, regardless of how good your content is. Review these when you assess a design. Our guide to news site design patterns covers the accessibility and performance standards worth testing against.
What should you check before choosing a theming system?
- Which template language does it use, and is it documented?
- How does it choose a template for each kind of page?
- How do you override a vendor template without losing changes at update time?
- Can editors change layout options without a developer?
- How is the final HTML structured, and who is responsible for accessibility?
Our feature checklist turns these into a form you can fill in, and What is a CMS? puts theming in context with the other parts of the system.
Questions people ask
What is the difference between a theme and a template?
A template is a single file that controls how one kind of page is rendered, such as an article or a section front. A theme is the complete package of templates, styles and scripts that gives a site its look.
Do I need to know PHP to edit a theme?
It depends on the system. Some use PHP files directly, while others use a dedicated template language such as Twig or Handlebars that limits what a template can do. Either way, editing a theme is a developer task, not an editorial one.
What is a child theme?
A child theme is a customisation layer that inherits from a parent theme and overrides only the files you change, so that parent updates do not overwrite your work. Not every CMS offers the pattern, so check yours.
Can I change my theme without losing articles?
Usually yes, because articles are stored separately from presentation. What you can lose is anything stored in the theme itself, such as custom fields or layout options, so check what depends on the old theme first.
Sources
- WordPress developer documentation describes the template hierarchy as the system WordPress uses to decide which template file to use for a page, and says WordPress searches down through the hierarchy until it finds a matching template file. — source, checked 10 October 2026.
- WordPress developer documentation says WordPress matches the query to a page type, selects templates according to the hierarchy order and uses the first matching template file in the theme directory. — source, checked 10 October 2026.
- WordPress developer documentation says that if no more specific template matches, the theme's index.php file will be used. — source, checked 10 October 2026.
- WordPress developer documentation lists the order for category pages as category-{slug}.php, category-{id}.php, category.php, archive.php and then index.php. — source, checked 10 October 2026.
- Drupal documentation says Twig is a template engine for PHP, that Drupal's Twig templates use the .html.twig extension, and that Twig's separation of template logic from PHP code provides a more secure environment. — source, checked 10 October 2026.
- Drupal documentation says developers can override all templates used for HTML markup. — source, checked 10 October 2026.
- Craft CMS documentation describes Twig as a fast and powerful templating system commonly used to power front-end views in content management systems like Craft, Drupal and WordPress, and says Twig code is marked with the delimiters {# #}, {% %} and {{ }}. — source, checked 10 October 2026.
- Ghost's documentation says Ghost themes use the Handlebars templating language, which creates a strong separation between templates (the HTML) and any JavaScript logic with the use of helpers. — source, checked 10 October 2026.