Why SSI and a Secret to Working Toplists
by Old Tom
What is SSI, and why might you want to use it? SSI stands for Server Side Include, but what does that mean?
An include file is a file that gets included. It's that simple! A server side include file, is a file that the server inserts into your web page before feeding it to your browser. For example, you might put a web page on your server that looks like this:
<html><head>
<title>My Title With Keywords</title>
</head>
<body>
<!--#include virtual="navbar.html" -->
<h1 align=center>My Title With Keywords</h1>
<p>Yada yada...</p>
</body></html>
Assuming you have your server set up correctly, your server replaces the line:
<!--#include virtual="navbar.html" -->
...with the contents of the file navbar.html. Incidentally, you can name the file anything you want. navbar.html, navbar.txt, or navbar are just fine. You could even name it navbar.gif, but that would surely lead to plenty of confusion later on. It is a plaintext file containing HTML instructions, not a graphic as the .gif filename extension would imply!
Your include file can be anywhere on your server, so long as it is on the same domain. Here's an example. Right now, as you look at this page, you're looking at a page in The DFN Weekly. I can put a file called navbar.html in the same folder. Go ahead and click the link, so you can see it's there! The file looks like this:
<table border=1 cellspacing=3 cellpadding=1>
<tr>
<td><a href="http://www.vnwr.com/dfn
/032404/index.html">First Page</a></td>
<td><a href="/dfn/032404/page2.html">Newbie Project of the Week</a></td>
</tr>
</table>
The NPOW (Newbie Project of the Week) link can be written any of three ways. Slow down, read the following carefully, make sure you understand the distinction. It's a simple distinction, but only if you follow what I'm saying:
- http://www.vnwr.com/dfn/032404/page2.html - I call this a "full" or "absolute" URL. You can use this full URL on any web page anywhere on any domain on the planet, and it will be correct. This is the "universal" locator for that web page. "URL", you will recall, stands for "Universal Resource Locator."
- /dfn/121703/page2.html - I call this a "domain-relative" URL. You can use this URL on any web page anywhere on the same domain. This might seem a poor compromise... why not begin with the http://www.vnwr.com and be done with it? Especially if your domain name itself does well in the Search Engines? You are absolutely correct - except when it comes to SSI. To make SSI work for you, you need to understand domain-relative URLs. So long as you understand the idea of saying where a web page is, relative to the domain root, you'll be able to set up your SSI correctly.
- page2.html - I call this a "plain" or "non-absolute" URL. For this to work, the file must be in the same folder as the web page mentioning it. You probably have used this type of URL many times, when using graphics on your web page that are in the same folder as the page. You might write, for example, <img src="logo.jpg" border=0> or <a href="pic01.jpg"><img src="thumbs/pic01.jpg" border=0></a>. Both of those are "non-absolute" URLs, because they only work on web pages in that particular folder. Move the web page without moving the graphics, and you have broken links.
Voltar generally recommends the first form, that is, the "full" URL beginning with http://. There are a number of reasons he suggests doing that - including the possibility of playing better in the Search Engines, and the fact that you can move the page to any folder on any domain without ever having to edit the page. When you build mirrors and doorways, that is an extremely valuable technique.
Unfortunately, when using SSI, you can't point to the SSI file with a full URL. You must use the second or third form. Can you see why? SSI only has one rule, but you must follow that one rule. The SSI file must be on the same domain. Therefore SSI actually has a second rule - that rule being that you can only point to the SSI file using the second or third form of URL.
(Incidentally, if you use the ErrorDocument directives in your .htaccess files, it pays to understand the distinction between full URLs, and domain-relative URLs. Check the documentation for details.)
To summarize, then, you can have navbar.html be part of your web page using either of the following two lines:
<!--#include virtual="navbar.html" -->
<!--#include virtual="/dfn/032404/navbar.html" -->
Be sure you get that #include virtual= stuff exactly as shown above. I usually go straight to the official document and make sure I have it correctly, copying and pasting their example.
Why bother to use SSI? It's confusing; you need your server configured correctly; what you see with your browser is different from what you see with ftp. Keeping track of that SSI stuff can get to be a total mess. So... why bother?
This very example shows a good time you might use it: When your site uses the same "navigation bar" on several different pages. Rather than copy and paste the same material over and over, just put the #include directive in each page. Suddenly all pages have the same navigation bar! As your site grows and mutates, you only need to change one file, to change the navigation bar on all pages.
Did you notice that the NPOW link points to the wrong page? No problem... just correct the line in navbar.html, and every page has the corrected link. Have you ever copied and pasted the same typo to page after page after page, only to have to go back and fix every one of those pages? If you had used an SSI file for that "copy and paste" information, you'd only need to correct it in the one place. (On the other hand, keeping millions of little SSI files around can cause more trouble than they're worth. Limit the technique to places with a big benefit.)
You can do something similar with your traffic flow. Jojasa and I, for example, have an HTML table item which promotes our AVS premium sites. Many different pages #include that same table. When we add another AVS premium site, we add it to the table, and suddenly all pages have the updated table. Very nice!
the sponsors of the DFN Weekly yet?
Well what are you waiting for?
Check them out NOW!




