pagehaus

Server Side Includes

Write your header and footer once and include them in every page, without any build tools.

Include a file

Put the shared part in its own file, e.g. includes/header.html, and include it where you need it:

<!--#include virtual="/includes/header.html" -->
<h1>About us</h1>
<!--#include virtual="/includes/footer.html" -->

virtual paths starting with / are from your site's top folder; without it they're relative to the current page. file="footer.html" also works, relative to the current file.

SSI works in .html, .htm and .shtml files, and included files can include others.

Per-page values

Set a variable before the header and use it inside, for example for the page title:

<!--#set var="title" value="About us" -->
<!--#include virtual="/includes/header.html" -->

<!-- in includes/header.html -->
<title><!--#echo var="title" --></title>

Dates and file details

Last updated <!--#config timefmt="%B %e, %Y" --><!--#echo var="LAST_MODIFIED" -->
Today is <!--#echo var="DATE_LOCAL" -->
The brochure is <!--#fsize virtual="/brochure.pdf" -->

Other variables: DOCUMENT_NAME, DOCUMENT_URI, QUERY_STRING, HTTP_HOST.

If an include can't be found you'll see “[an error occurred while processing this directive]” in the page: check the path. #exec isn't supported.