How To Include HTML in Many Documents Using SSI

Server Side Includes can make managing repeated content much easier

On all Web pages, there are areas of that site that are repeated over and over again across many or even all of the pages in that site. This could be structural areas of the page, like the navigation or the footer, or it could be content, like a company's address and contact information. You can add this content to the code of each individual page that needs it, but that makes editing that content later if it needs to be changed a big project, since you need to change it across every page of the site.

If you want to have the same content repeated across many pages of your site, but you do not want to manage that content on an individual, per-page basis, you can use Server Side Includes or SSI. Server Side Includes are PERL-language based commands that allow information to be gathered from the server. If you have SSI on your server, you can write one file and then include it on your web pages where you need it.

SSI requires that you have it installed on your Web server. Contact your system administrator if you’re not sure.

Step by Step Instructions

  1. Write the HTML you want repeated and save it to a separate file.
    I like to save my include files into a separate directory, usually “includes”. I would save my copyright information in an include file like this:
    includes/copyright.ssi
  2. Open the web page where you want the include file to display.
  3. Find the location in the HTML where the include file should display, and place the following code there:
    <!--#include virtual="includes/copyright.ssi" -->
  1. Change the path and file name to reflect your include file location.
  2. Add that same code to every page you want your copyright information on.
  3. When the copyright information changes, edit the copyright.ssi file. Once you’ve uploaded it, it will change on every page of your site.

Tips

  1. You can include HTML or text in an SSI include file. Anything that can go in an standard HTML file can go in an SSI include file.
  1. You can put SSI includes anywhere in your HTML document, including the head.
  2. Your readers will not know you’re using SSI unless you name all your files .ssi or .shtml. The pages will display as plain HTML.

Other Options

In addition to SSI, you can also use include files, either with PHP or ASP, to achieve the same results.

Many Web sites today use a CMS, or content management system, as the underlying base for the site. These software platform often use templates or themes for the pages in the site. Since these templates are used by many pages, a change to the one template will be reflected on all the pages that use that template. This is very similar to using SSI or include files in that it allows you to make one change that will affect more than just one Web page.

In end, there are a number of options available if you want to make managing a Website, and content that is shared across multiple pages of that site, easier for you.

Edited by Jeremy Girard