The following templating concepts are optional. As an alternative, you can simply use the final HTML files from the dist/ folder.


With Nunjucks, you'll be able to compile the HTML source files from src/html to dist/ using a rich and powerful templating language. You can read more about Nunjucks on the official website

Nunjucks Variables

A variable looks up a value from the template context. If you wanted to simply display a variable, you would do:

This looks up username from the context and displays it. Variable names can have dots in them which lookup properties, just like javascript. You can also use the square bracket syntax.

  1. - reading variables
  2. - setting variables

Nunjucks Template Inheritance

Template inheritance is a way to make it easy to reuse templates. When writing a template, you can define "blocks" that child templates can override. The inheritance chain can be as long as you like.

If we have a parent layout template in src/html/layouts/example.html that looks like this:

Then a child template or page from src/html/pages/my-page.html can extend this layout:

The output in dist/my-page.html would be:

  1. - template inheritance concept
  2. - rendering the parent block
  3. - extending a template
  4. - template sections
  5. - include template partials

Front Matter

Any page in src/html/pages can contain a YAML front matter block and will be processed as a special file. The front matter must be the first thing in the file and must take the form of valid YAML set between triple-dashed lines. Here is an example from src/html/pages/index.html: