Yale University Library

 

Workstation and Technology Services

Quick Links

Server-Side-Includes on www.library.yale.edu

What is a Server-Side-Include?

It can mean several things. Here we are using it to insert text from one file into another file automatically when that file is sent to the browser. A common use would be to have a standard footer that is automatically appended to multiple pages. It doesn't HAVE to be a footer. You can insert at the top, in the middle, anywhere.

Note: The file includes the Server Side Include must have an extension of .html.

How to make a Server-Side-Include

  1. Start with the html file you want to use: example.html
  2. You need to have a file to include: footer.html
  3. Add the include tag where you want to insert the text from another file:

    <!--#include file="footer.html"-->

    or

    <!--#include file="includes/footer.html"-->

You don't have to put the included file in the same directory or subdirectory of the same directory. You can refer to files anywhere, but the syntax is slightly different:

<!--#include virtual="/~coleman/includes/footer.html" -->

Notice that this is the same as the path you would type into a browser, minus the http://www.library.yale.edu.

Notes

  1. Server-side-includes are ON for the entire web server.
  2. The server will NOT send a "Last Modified" in the header when the page is retrieved. This is because the page is "recreated" each time you ask for it. If you really want the Last Modified of the page you can use a Server-Side-Include for this too!

    <!--#flastmod virtual="/~lso/workstation/docs/ssi/example.html" -->

  3. If you "view source" with a browser, you will not see the include code. That's because the server "creates" the file for you each time you request it.

john.coleman@yale.edu
http://www.library.yale.edu/~lso/workstation/docs/ssi/
Revised: 7/23/2001