Web Design
Server Side Includes
Beginners Level
SSI Demo Notes Page
A simple Server Side Include Demonstration
(How to include the contents of a seperate file into all your web pages)
Notes Page
[Use the Back Button to return to ssidemo page]
Notes
Note1 -
menu.txt is an arbitary name I have chosen for this example. If you use Dreamweaver for instance and wish to use it to edit these external text documents then an alternative extension of .ssi might be more appropriate (menu.ssi) will be recognised as a Dreamweaver associated file, and will work just as well.
Note2 -
Placing the file in the site root means you don't have to worry about specifing
long path names.
Any .shtml files already in your site root need only specify "menu.txt" in
the include statement.
Any .shtml files nested in sub directories of your site need only specify "/menu.txt" in
the include statement.
Note3 -
It is important (unless you can configure your server otherwise) that all
files you wish to use SSI directives with are given the .shtml or .shtm extension
in place of the usual .html or .htm .
Web Servers are (by default) set up to look for SSI directives only in files
with these extensions.
Ordinary .html or .htm files are no different in reality but are not searched
by the server for SSI directives. Therefore they will not get processed (eben
if they contain any).
The main reason for this is so the server only searches file types it knows
might contain these directives - searching every single .html file in your
site is a waste of time and resources, also slowing the load times of your
web pages.
Note4 -
If you place your menu.txt file in a sub directory (/scripts/ssi/ for example) then you will need to reflect this in your include statement. Using my example above the statement changes to :-
<!--#include virtual="/scripts/ssi/menu.txt" -->
It is in my opinion then that you place your menu.txt in the site root instead (See also [ Note2 ])

