Skip to content Skip to site navigation

Server-Side Includes

Server-side includes (SSIs) are a way to tell the server to do something a little extra when it's handing out your file. One common use is to attach a footer to the bottom of each of a set of web pages. The footer is kept in a separate file that is "included" by the server when it delivers your page. A change to the footer then only has to be made to that file, instead of to the bottom of every page.

Other things you can do besides include a file are show the time of the last change to a file, its size, or print an environment variable. The following are some sample snippets of HTML you can use:

You can find more examples and a tutorial on how to use server-side includes here.

In order for your server-side includes to take affect, the HTML file must have the extension ".shtml" which tells the server to parse the file for the include commands.

Below are some caveats for using server-side includes:

For more information, you can read the Apache documentation on mod_include.

  • Print out today's date:
    <!--#echo var="DATE_LOCAL" -->

  • Print out the last modification date of the index file:
    <!--#flastmod file="index.html" -->

    • If you try to get the size or last time modified for a file system link, you'll get the info for the link and not the file it points to.

    • Since the server must parse any page with server-side includes before handing it to the browser (as well as retrieve any included files or other requested information), pages with SSI's will take longer to load. Be judicious in their use.

    • You cannot use the #exec command on the servers.

Last modified January 8, 2020