Building Themes
Themes are an essential part of a content management system. They define the way your content is presented to the visitors of your website. Automad's flexible and intuitive template language enables also inexperienced developers or beginners to create themes and templates on their own. In case you are an experienced PHP developer and you need more unusual features, you can also develop templates using plain PHP.
Check out the Theme Skeleton theme and the Cheat Sheets to get started!
Structure
An Automad theme is actually not more than a bunch of templates, a theme.json file, some CSS files and possibly some Javascript files, grouped within a directory under packages
. While it is not required, it is recommended to create a unique directory as your namespace and place your theme in there as shown here:
packages/
yournamespace/
yourtheme/
css/
js/
template.php
page_not_found.php
theme.json
Note that all custom modifications to the Standard package are lost when updating Automad. Please copy themes to your own namespace (subdirectory), in case you want to keep any custom modifications on updates.
Templates
A template file is a simple .php
file containing HTML markup mixed with some template language code to render your content dynamically. While PHP is actually not required within the template file, the .php
extension must be used to identify a template.
Before you start to develop your own themes, take a look at the plugins page to install Automad syntax highlighting and snippets for your favorite IDE or editor.
Block Layouts
While blocks stack vertically by default, the Block editor allows users to also arrange them in grids nested in a section or even stretch them to cover the full width of the parent container. The underlaying flexbox wrappers are generated automatically by the render engine. However there are some things to be taken care of in order to make things work. You can read more here about optimizing and preparing your template markup to fully support all layout features.
Block Templates
Blocks with dynamic content — pagelist and filelist — can use custom templates to control the content and the style of the rendered output. Follow this guide to develop your own custom blocks.
404
There is also the option to add a custom template for a 404
page. Simply add a template with the name page_not_found.php
to design a custom error page matching the other templates of your theme.