Include
The include
helper can be used to include files into your pages; normally it is used for examples but can also be useful to embed assets. Relative paths are resolved from the file calling the include
helper unless they start with a /
which resolves the path from the site
folder.
It is an error attempting to include a file outside the site
source folder.
Use the includes folder conventions to automatically ignore included files.
If you use this helper inside a partial loaded from a plugin relative paths are resolved from the plugin partial file which is probably not what you want; instead use an absolute path to resolve from the project site
folder.
Arguments
String|Path
The file system path to include.
Parameters
binary
: Read the file as binary rather than a UTF-8 encoded string.base64
: Encode the file to base64.
Example
Use an absolute path to resolve from the site
folder:
Use a quoted string to include characters disallowed in paths:
A common technique for examples is to put the include
inside a fenced code block:
Embed an SVG file using a data:
URI:
Use the binary
parameter to embed a PNG file: