Include directive(file) Last updated: 02. Dec 2022
This is used for including the contents of one or more files into a web page. This could commonly be a common piece of code throughout a site, such as a page header, a page footer and a navigation menu.
Parameters
Name | Type | Description |
---|---|---|
file | string | Absolute file path (from the site root) to the specified file to include. |
Returns
The whole contents of another file.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.<html>
<body>
<!--#include file="Header.hash"-->
<section>
Page content.
</section>
<!--#include file="Footer.hash"-->
</body>
</html>
Output
The #JS code above produces the output shown below:<html>
<body>
<header>Contents of header.hash file here</header>
<section>
Page content.
</section>
<footer>Contents of footer.hash file here</footer>
</body>
</html>