You Need SSI Right Now!
by Bob McElwain
I learned of SSI (Server Side Includes) long before I built my current site. Since it seemed the only way to go, I checked it out once again for the new site to be.
What SSI amounts to is creating a new page for any elements common to all pages on your site. Then ask the server to include these pages whenever main pages are requested.
For example, build a regular HTML page containing all the content, including graphics, as is often used in the left column of a page as the basis of navigation. Then, instead of adding this content to each page, simply include the file. And hey, it's super. If you need to make a change, you make it only once, instead of on every page on your site.
SSI Slows Page Downloads?
What prevented me initially from using SSI were notes I read regards increasing page download time. Each page using included files needs to parsed (read) by the server to find any files to be included. Being an absolute fanatic about minimizing page download speed, I passed. Bad mistake.
Updating Multiple Pages Chews Up Time
Six month later, changing a single menu item was taking hours. I decided to ignore the page download time and go. But I ran into another snag. Pages with includes need the SHTML extension, else the server won't parse them. (An S in front of HTML.)
Switching From HTML to SHTML Busts Links
Nuts. I already had lots of incoming links. Since I didn't want to bust them by changing file names, I passed once again.
I had heard people speak of ways in which a server in some cases could be instructed to treat HTML pages as SHTML pages. But I didn't check it out. Another bad mistake.
The Perfect Solution
Many months later I ran across the following code. Add these lines to the top of your .htaccess file, and all existing HTML files will be parsed just as if they had the .SHTML extension. Neat. No changes in file names, which means no busted incoming links.
Options Includes AddType text/html .html AddHandler server-parsed .html
.htaccess is a hidden file in the root directory on your server. It is helpful in doing many things, and can be located elsewhere as needed, but for now let's focus on the above.
In WS_FTP, when you type -al into the blank field to the right, this file name will become visible. The best plan is to download the file, add the above code, then upload and overwrite the original. (The reason or downloading first is to be certain you hold whatever the file may already contain.)
What I did next was create a file, yleftnav.html, containing all the content in the left column of a page. Then on each page, I replaced the content in that column with the following.
Given the three lines above in the .htaccess file, each .HTML file is parsed for the include command. When found, the content of the file is included in the page at that point. You can see the results by viewing the source for one of my pages. And you can view the file included with ... http://sitetipsandtricks.com/yleftnav.html
The display of this page will be distorted, but it works fine when constrained by the first cell/column on each site page.
I'm also using ybotnav.html for the text links and contact info at the bottom of each page. Anything repeated on most or all pages can be handled in this way.
Finally Getting To It
I continued to avoid the chore for many months. And when I did get to it, hours disappeared quickly, for by then I had more pages.
But hey, I do love it. And there's good news besides. Those notes regards slowing page downloads (they're still around), appear to have applied in an earlier time when servers were slower. I haven't detected any increase in the download time for the pages on my site.
Get to this right now, before your site grows even larger. Whatever time it takes will be saved many times over on future changes required.
Before getting carried away, be sure to test to see that whatever code you choose works properly on your host server. If it does not, and your host can't help you, then you may be stuck with renaming page name extensions to .SHTML. Which also means changing links internal to your site. And losing any links to your site. (Even this option isn't available on all hosts.)
Here is another include command I am not using on my site. It assumes all files to be included are in /includes/, a subdirectory within the directory containing your pages.
Since my site layout is simple, and includes only three subdirectories for pages, I simply uploaded the files to be included to these three directories, and to the root directory. For me, this is a great solution for it takes only minutes to upload four copies. You might do better, however, with the above.
I should have done this years ago. Do it now. Or you'll be saying the same thing in a year or so. Honest, you will!
Bob McElwain, author of "Your Path To Success." How to build ANY business you want, just the way you want it, with only pocket money. http://sitetipsandtricks.com/opts/mcb.html Get ANSWERS. Subscribe to "STAT News" now! firstname.lastname@example.org