Include one file in another HTML file

a.k.a. Server Side Includes (SSI)

Using the med-info web fileserver
Home

How to:

Neat tricks:

More:

 

Often, there is content that you want to include on all the pages of your website, like a header or footer. You could enter this content into each file, but if that content changes, you'd have to manually change it in all your files. This alternative lets you create one file with the common content; any changes you make in that file will automatically be reflected in any page that includes that content.

For example, if you have a standard header contained in the file header.htm that you want to include within a file located in the same directory, use code like this:

 <!--#include file="header.htm" -->
If the file you want to include is not in the same directory as the HTML file you are editing, you need to use the "include virtual" format and specify the path for the file like this:
 <!--#include virtual="/mydepfolder/subfolder/header.htm" -->

Note that the file to be included should not include the standard HTML elements of <HTML>,<BODY> and <HEAD>, because they would be duplicated in the resulting web page, which could cause it not to display properly.


Document: http://www.med.umich.edu/umhswww/howto-includefile.htm
Last updated: Monday, 06-May-2002 14:34:56 EDT
Comments to: ASK-UMHS on Groupwise. If you do not use the UMHS Groupwise system, add @med.umich.edu to that to form a complete Internet address.