User Guides

Templating Introduction

Templates control how your websites content is displayed and are defined in your websites templates directory. As long as your templates are located within this directory, you can structure them however you would like.

LexasCMS uses Twig to parse its templates, Twig is an easy to understand templating language written specifically for designers. If you've never used Twig before, be sure to check out the Twig Basics section of the documentation before you continue.

Base Template

LexasCMS provides a base template (named layout.twig) that we highly recommend you use. It provides a base HTML document that automatically includes all of the defined styles/scripts and also takes care of including any required meta tags into your website. The template also includes a few blocks which can be used to insert any extra elements if needed.

Using the base template will allow you to get straight to work in just a few lines of code. You'll never need to skeleton out an HTML document again!

To use the base template, create a new template file at /templates/main.twig, the contents of the file are below:

{% extends "layout.twig" %}

{% block body %}
  This is the body of my web page!
{% endblock %}

Content Blocks

The table below displays a detailed overview of the available blocks on the base template.

Block Name Content Placement
headStart Immediately after the opening <head> tag.
headEnd Immediately before the closing </head> tag
body Immediately after the opening <body> tag
footStart Immediately after the content placed within the body block
footEnd Immediately before the closing </body> tag