Server Side Includes
The often maligned, Server Side Include can actually be very helpful in managing common page sections. Using somewhat obscure techniques you can even use SSI to control page areas that feature variable content.
Useful For
- Static, recurring elements (i.e. headers, footers)
- Global navigation
- Dynamic navigation
- Spotlights / callouts
Common Complaints
- I use dreamweaver, why bother with library items and templates?
- I use dreamweaver and I like the WSIWYG mode
- When am I ever going to update those parts of my site anyway?
- I don't want to name my files .shtml and break links
Rebuttal
- It's faster and more reliable
- Newer versions of dreamweaver can display SSIs
- You'd be surprised, ever see a copyright statement like this:
"Copyright (c) 1995-2001 Massachusetts Institute of Technology"?
- Ahh, but you don't have to...see "XBitHack" below
SSI lets you embed a number of special 'commands' into the HTML such as displaying when a file was last modified, inserting another HTML file, or echoing a string of characters when an 'if' expression is true.
The most common use for SSI is to have the same footer display on every page. The footer is a separate file that gets pulled in by the server when a browser requests a web page with an included footer. We will use this page as an example. To create an included footer, create an HTML file called footer.html with the footer information you want. To insert this footer into your page, add the following code at the end of the document
<!--#include file="footer.html" -->
Then name your page with the extension .shtml instead of .html or .htm. To see your file with the footer included, view the .shtml file in a browser. If you name a file index.shtml in a directory, and no index.html is present, index.shtml will load as the default page for that directory. The syntax is similar for other includes.