Templates
Templates define the layout and structure of your site’s pages. Instead of rewriting the same HTML over and over, you can define a template once and reuse it across multiple pages. Templates are saved with a .tmpl extension in the templates/ directory.
In your page’s [HEAD] tag, use the template attribute to choose which template file should be applied. Do not include the .tmpl extension in the attribute value. The following example will use the templates/custom.tmpl file for the template.
[HEAD template="custom" ...
Template Variables
Templates indicate content insertion points using shortcode tags. Unlike page shortcodes, templates and widgets do not require the closing "/". Inside a template, you can insert values from three different sources, in the following order of precedence:
Pages
The template will first check if there are any page level Shortcodes that match the tag name.
// Example using CONTENT reserved word [CONTENT xyz="abc" /] // Example using enclosing shortcode [XYZ]abc[/XYZ]
If none are found, it will then check for attributes on the [HEAD] tag for matches.
[HEAD xyz="abc" /]
Defaults
Next, the template will check the defaults in the config.json file.
"defaults": { "xyz": "abc", }
Globals
Finally, the template will check the globals in the config.json file.
"globals": { "xyz": "abc", }
Example
In this example, the code below can be placed in a widget or template, and will allow the page to insert the custom value of "abc" into that location.
Hello World! The value is [XYZ].
When the compiler generates the static pages, the final output will be:
Hello World! The value is abc.