Server Side Includes

Server Side Includes are a simple way of distributing common content across a website. Take, for instance, a menu system. If you run a site with X amount of HTML pages then you would normally have to change X pages of code in which the menu system is used. It’s OK if you can do a global find & replace, but by using server side includes you can change one menu in many pages by changing one file.

Getting Started with Server Side Includes

So, you have a menu system in your HTML pages. If you were organised when you built the site it’s either in a table or a div, nice and tidy and easy to isolate, copy & paste, right?

Grab the menu system source code by copy & pasting it into a new file. The code can go into the new file by itself without any html, head, title or body tags. Save this file to an appropriate place on your server; you could create a folder called /ssi in the root of your server and save it there as, say, menu.html

In your page, where you removed the menu from, replace the “gap” with the code

For PHP

<?php
include ("https://www.yourdomain.com/ssi/menu.html");
?>

If you aren’t using PHP then another method is to save your menu system as a file named menu.inc, again save it in the /ssi folder. Remember to change the extension to .inc

Normally you would have to call the include in through an SHTML page, basically a page with the .shtml extension. However, you can configure your server to read .htm or .html files and deliver server side includes.

<!--#include virtual="/ssi/menu.inc" -->

NB: This article is 20 years old now  Server Side Includes were great when I worked on a massive static website like the is4profit.com B2B business advice website, just prior to moving to a full CMS. But today WordPress does it all for you.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top