Skip to main content

Nested templates

You can nest temlates as much as you want, pufferfish will always look in your templates to expand other templates.

Example​

Consider the following file structure:

Project
â”” html
| â”” index.html
â”” templates
| â”” footer
| | â”” contact.html
| | â”” social.html
| | â”” copyright.html
| â”” footer.html
â”” output
â”” Config.rb

This folder structure is the recommended way to structure a project. The Config.rb file is the build file explained in the Compiling html chapter, in this example we are using the exact same file.

Our files are the following:

index.html
<html>
<head></head>
<body>
<main>
<p>This is my main content!</p>
</main>
%footer%
</body>
</html>
footer.html
%footer/contact%
%footer/social%
%footer/copyright%

The example above will replace %footer% in our html with

<!--Contents of contact.html-->
<!--Contents of social.html-->
<!--Contents of copyright.html-->