Include(path, [template]) Last updated: 17. Oct 2026
Include a file or template into another page.
include2 is an internal variant used while rendering included documents — do not call it yourself.
See also: Path traversal Include directive - INCLUDE ERROR, FILE NOT FOUND: include file="..." import - import functions and values from another JS file load
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path of file to include. |
| template (optional) | string | If referring to a Docly document with a schema that include templates. |
Returns
The file's content — for a file with #JS code, the executed result. With a template, the document generated through that template, or the generator's error message if generation fails.
If the file is not found, the text Unknown file <path> is returned (no error is thrown). A file that includes itself, directly or through other files, is stopped with the text Infinite include loop stopped for …. The same file can still be included several times on one page.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.<html>
<head>
<title>Test</title>
</head>
<body>
#include("#/Test-header.html")#
<article>
Content here ...
#include("Frontpage", "Article.html")#
</article>
#include("#/Test-footer.html")#
</body>
</html> Output
The #JS code above produces the output shown below:<html>
<head>
<title>Test</title>
</head>
<body>
This is content placed in the file Test-header.html.
<article>
Content here ...
Unknown file Frontpage
</article>
Test-footer.html file contents.
</body>
</html>