Web Hosting Support Center
SSI Overview & Instructions
Home : Hosting Documentation : Using Server Side Includes


Server Side Includes (SSI) is a feature of CGI (embedded in your server) that enables you to dynamically insert a piece of information (including the current date, text file, and HTML file) onto any Web page. The browser, either Netscape Communicator or Microsoft Internet Explorer, displays the inserted code as if it was hard coded onto that page. For example, if you are interested in displaying the current date and time on your Web page, add one simple SSI code onto the page:

<!--#echo var="DATE_LOCAL" -->

SSI empowers your Web pages to be more responsive and make maintaining your site an easier task. So, instead of manually editing your Web page and change the date to the current one each and every day.

What do I need to use SSI on my site?

Every account supports Server Side Includes automatically!
IMPORTANT: in order for SSIs to work, your file must be named with the ".shtml" extension.

That's great; What other options can I use SSI for?

Now, you know what SSI can do. Here are some other useful options you can do with SSI:

  • Display the current date and time in many different formats;
  • Display the last modified date of a Web page;
  • Insert/Include a document inside another; and
  • Execute a CGI script or a command directly from the Web page.

 

  • Display the current date and time:
    To display the current date and time, add the following SSI code to your Web page:
    <!--#echo var="DATE_LOCAL" -->
  • The result is the following:
    Thursday, 28-Mar-2024 17:49:00 EDT

 

  • Display the last modified date of a Web page:
    To display the last modified date of a Web page, add the following SSI code to it:
    <!--#flastmod file="ssi.htm" -->

    The result is the following:
    Friday, 24-Aug-2000 11:48:40 EDT

 

  • Include a document inside another:
    This must be one of the most useful features of SSI- the ability to include one document inside another. For your information, SSI supports relative/absolute paths.
  • The SSI code for this is:
    <!--#include file="your-file.htm"--> (relative path)
    <!--#include file="/pages/your-file.htm"--> (absolute path)
    <!--#include file="../your-file.htm"--> (relative path)

    Put that code inside your Web page, and your-file.htm shows up in the specific place where the SSI code inserted. The file doesn't have to be a ".htm" file. It could also be a ".txt" file (ie: your-file.txt, your-file.inc, your-file.text). 

    So how is this useful? Let's say you have a piece of information that is repeated on many pages of your site (a navigational bar, for example). By saving that piece of information as an individual html or text file, and using SSI code, updating that piece of information becomes merely changing that ONE file. Moreover, the changes is instantly reflected on all pages containing the SSI include command. 

    So, instead of manually editing all the pages, updating your-file.htm will save you a tremendous amount of labor time.

     

  • Execute a CGI script or command directly from the Web page:
    SSI allows you to execute a CGI script or command directly from the Web page. This is where SSI becomes not only handy, in many cases. It's not a feature you would use by itself, but in conjunction with a CGI script you have installed. CGI scripts require that it be called from the Web page, which SSI can do. The SSI code to call a CGI script from the Web page is:
  • <!--#exec cgi="/cgi-bin/your-script.cgi"-->

    Here is an example of a cgi script called using the above SSI code:
    Hello, World!




    For an extended Server Side Includes Tutorial, click here.


 © Contains copyrighted material.
Duplication without permission prohibited