#
#
#end
The Silicon Guide To
Using Server Side Includes
Including Files
This is where the big time saving comes in. By
using the include command, you can insert the contents of any text file (which can contain
html) into the current HTML document.
Syntax:
<!--#include
virtual="LOCATION_OF_FILE"-->
where LOCATION_OF_FILE is a regular path to the file
you want to include (this can be relative as in "ssipages/menubar.shtml" or
direct as in "http://yourdomain.com/ssipages/menubar.shtml").
For instance, if you want to include a top
navigation bar, that will be the same in all your pages, your HTML pages would look as
follows:
<html><head><title>My Home
Page</title></head>
<body bgcolor=ffffff>
<!--#include virtual="menubar.txt">
<h1>Welcome to my Site</h1>
<p>Here you will find lots of useful information</p>
</body></html>
where <!--#include
virtual="menubar.txt"> would be replaced by the content found in the file
menubar.txt. This allows you to simply edit menubar.txt whenever you wish to modify
your navigation bar, and the changes will take affect on all pages that included the
content of that file. No more modifying every darn page on your site just to change
content that is the same across all your pages.
This is what we do here at Silicon Guide, as you may
have noticed that all our pages end in .shtml. However, we use a different menu bar
file for every section. The footer at the bottom of all the pages, is also located
in only one file. Of course, if you check our source you won't see the actual SSI
commands, since the server replaced them with the actual content they were ment to
display.
Many other sites use SSI in this way, AltaVista being one of them.
Your server side includes may not work if you use
them within a file that is being included, however naming the included file with .html or
.shtml instead of .txt (or any other extension) often solves the problem.
Next Page:
Executing CGI Scripts
Skip Ahead:
SSI Hosting and Conclusion