top left
The HTML Source Logo

Top Right
 Getting StartedHow Do I...TroubleShootingPromotionContact Us
advanced search

Getting Started
HTML Cheat Sheet
Webmaster Tools
HTML Help Forum
Color Codes
Link to us

Using SSI (server-side include)

What Is It?

Do you have a large site, do you have something that is on every page in your website, such as a navigational menu? Well SSI (server-side include) maybe for you. SSI can be your best friend, most websites with a similar layout on each page use SSI. If your observant, and most webmasters are, you may have noticed an .shtml extension on some big websites instead of the traditional .html extension. The reason it is .shtml and not .html is because that page uses SSI. You may notice how each page with that .shtml extension has something that is on every other page with that .shtml extension.

Even uses SSI.

If your asking why if we use SSI on the site, this page's extension isn't .shtml. It's because our server doesn't require the .shtml extension. So we can use a regular .html extension. However most servers do require the .shtml extension.

Back to the subject, notice how each page on this web site has the same basic layout, the same left menu, and top navigational menu. What if I wanted to add a link to the left menu, I would then have to add the link to every single page on the site, right?

Wrong, thanks to SSI webmasters don't have to go to each page individually to update there site.

Basically SSI allows you to update 1 file, and it will then effect every other page you want it to. You can effect thousands of web pages by editing 1 simple file.

How to use it

You have to have SSI enabled on your server. Most servers do, for example does. If you don't know if your server allows SSI or not, you should ask them. If your lazy, just try it, if it works, your server allows SSI, if not, it doesn't.

First take the piece of script you want to have on a bunch of pages, for this example, well use a left navigational menu like the one on this site.

Now make a text file, you can use Windows Notepad (or whatever program you want that allows you to save text files), and place the script in there.

Then Save the file with a .txt extension. For example leftnavagation.txt

Next, upload that file to your web site.

Now for every page you want the left navigational menu on (or whatever script you put in the .txt file), change the ending .html file extension to .shtml. For example if you have a page called index.html change the file name to index.shtml

(This is not required on some server's, but most do, if you have a large amount of pages, and you don't feel like adding the .shtml extension to each one, you can try this using the regular .html extension, if it doesn't work, you need to change it to .shtml.)

Next, for every web page you want the menu to be on, add the following code where you would like the menu to be, so for example if I wanted the menu to be at the bottom of the page, I would place this code at the bottom of the page:

<!--#include file="yourfilename.txt" -->

Just replace yourfilename.txt with the actual name of the file you saved.

Now when you edit the .txt page, it will effect each page you put that script on.

Trouble Shooting

SSI can be tricky, and doesn't always work on the first try, here's a few things to try if your having trouble.

Are you putting the .txt file in the same directory as your web pages?

The code <!--#include file="bottom.txt" --> is for the pages that are in the same directory as the .txt file.

The thing to do is place your .txt file in your main web site directory.

For web pages in one directory up, add a ../ before the file name, example:

<!--#include file="../bottom.txt" -->

For 2 directory’s up use:

<!--#include file="../../bottom.txt" -->

and so on...

On some servers, you need to use the word virtual instead of file in your code, like this:

<!--#include virtual="bottom.txt"-->

Company   |   Careers   |   Partners   |   Advertising   |   Help
Privacy Policy   |   Trademark Notices   |   User Agreement
© 2001, INC. All Rights Reserved.

Site hosted by Build your free website today!