Server Side Includes Tutorial (SSI)
If you have never heard of or used a Server Side Include (SSI) before, then you must read this post, as a Server Side Include is one cool way to insert content into your web page. When you use a Server Side Include the server takes the entire content of one file and places it onto your page, where you specify it. A Server Side Include would be used for such things as a navigation menu on a site, where the navigation menu is re-used on many or every single page. By using a Server Side Include, when you go to update the menu, you only have to update one file instead of every page that has the menu, makes sense huh?
I would recommend to use a Server Side Include where ever content is re-used across many pages. On many websites this includes the header, footer and navigation menu. A Server Side Include saves you serious time when you need to make a site wide change. You simply edit the include file, upload it the the change is automatically made site wide.
How to do it:
- Select & copy the code from your web page that you wish to re-use across your site.
- Create a file & past the code from step 1 into it. Name this file with the extension .htm, .html, .asp, .aspx or .php.
- Select the file from step one, and insert this code into the area where the old code used to be (choose one depending on technology used):
- PHP: <?php include(“./relative-path-to-document”) ?>
ASP or SHTML: <!–#include file=”./relative-path-to-document” –> - Ensure that any pages with the code from step 3 ends in either .shtml, .asp, .aspx or .php. If you name the file ending in .html the SSI will not work.
You can click here to download a working example.







RSS
December 27th, 2010 at 10:27 pm
I really like your website and i really appreciate the great quality content you are posting here for free for your online readers. Thanks.