What are Server Side Includes, and how do I use them?

Server Side Includes (SSI) are codes you can add to your HTML document that tell the web server to include other content with the document being served. For example, you can use an #include statement to display the same header and footer on your pages automatically; if the information changes, you can save time by editing a single header.html or footer.html file. You can also use SSI for graphics such as logos or image maps that should appear on multiple pages.

On Webserve accounts, pages that use SSI (#include statements) need the .shtml extension. Included files can have other extensions (e.g., .html).

Note:
The #exec command is often used to run a CGI or Perl program from a web page; for security reasons, the #exec SSI is not enabled on Webserve.

Using SSI with files in the same directory

In SSI, the #include statement tells the server to include another file:

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

You can use SSI to display banner and header information, as in the following example:

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

In the above example, the #include statement appears in the body of the document, immediately after the <body> tag. In SSI, the process of including takes two separate files and creates one whole file. The server takes the SSI page and inserts it into the page calling it.

Using SSI with files located in different directories

If the SSI calls a file that is located in another directory in the account, use #include virtual instead of #include file. For example:

<!--#include virtual="../header.html" -->

In the above example, the header.html file is located in the directory above the location of the file referencing it.

Footers

The footer for this page is created dynamically, so that the date that the file was last modified automatically appears in the footer. The server side include statement calls another .shtml file, using this code:

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

The footer statement on this page is placed at the bottom of the file, just before the </BODY> tag.

For more about using SSI on Webserve, see Server Side Includes tutorial.

This is document bfsa in the Knowledge Base.
Last modified on 2017-05-16 11:42:03.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.