Server-Side Include Tutorial

This document and its links are meant to increase your awareness of a very useful outgrowth of the ever-expanding WWW, SSI. That's S for Server, another S for Side, and an I for Include(s). Sadly, the hyphen is not represented in the acronym. :(
The name explains what is going on here pretty well; a SSI is a piece of code that lets the server know that it has to include something. What can be included? Well I'm glad you asked, my intrepid web-weaver. These tricks work for many servers, including the one this document resides on, so check with your sysadmins to see if you can play the SSI game with me!

My Favorite Areas of SSI:
Dates and TimesModular Web Weaving!Even More...

Modification/Current Dates and Times

How annoying is it to always have to change the part of your page that says, "Last Updated: .."??? It bugged the hell out of me, and I was so happy when I discovered this part of SSI, which will do the work for you! You just need to type in the right code. Now for all SSI, the format is very similar to an HTML comment, with the whole <!--comment--> deal. okay, so you want to put this on your page. Well. This page was last updated on . Pretty cool, huh?? Oh, you doubt the power of SSI? Well the current time is . Go ahead and reload, if you doubt me!!

Now that I have you entranced, I'll tell you how this is done. The SSI call I am using is called echo, and it is used like this:
<!--#echo var="SOMETHING"-->
where SOMETHING can be DATE_LOCAL if you want the current date and/or time, or LAST_MODIFIED if you want the last modified date/time. So the standard last modified call, when you type it in, looks like this:
This page was last updated on <!--#echo var="LAST_MODIFIED"-->
This still leaves you with a problem, though. You still may want to say something other than what your server returns as the default. for this, you need a new call, config. This call will configure your date and time settings for any echo call. You can have multiple configs, too; each echo just looks backwards in the document until it finds a config, and it uses that one. So to make my last modified bit look better, I'd say this:
This page was last updated on <!--#config timefmt="%A, %B %d"--><!--#echo var="LAST_MODIFIED"-->
DON'T FORGET THE QUOTATION MARKS! And those % thingees are the parameters you are setting. Here is a list of useful ones:

Day of week:
Abbreviated day of week:
Month of year:
Abbreviated month of year:
Date & time, as formatted per local preferences:
Day of the month:
Hour of the day in military (24-hour clock) time.
Hour of the day in standard (12-hour clock) time.
Day of year.
Minutes past the hour:
Month of year [01-12]:
AM or PM:
Seconds past the minute:
Week of the year, [00-53]. Sunday as the first day of the week,.
Week of the year, [00-53]. Monday as the first day of the week.
Weekday as a decimal number, [0-6]. Sunday as the first day of the week.
Time, as formatted per local preferences:
Date, as formatted per local preferences:
Year, 4 digits:
Year, 2 digits:
Time zone name:
Good luck! I hope this makes your web-weaving a little bit easier!
Dylan Humphrey
Swarthmore College Class of 1998
Modular Web Weaving!

When you are managing an entire site, it can get real boring, having to retyp the same old thing at the bottom, or top, of every page. SSI saves your ass from utter boredom here. The call in this arena is called include and it saves me a lot of time; it will do the same for you!
I like to put the following at the bottom of my pages, with a link to my homepage and a mailto: to me:
Dylan Humphrey |

instead of having to type the HTML for that in over and over, though, I can just save the above text as something, and attach it with SSI. Say I called it "footer." The SSI call would be: <!--#include file="footer"-->. Note that here, file is looking at the relative path, so footer has to be in the same directory, or you would have to include the pathname, ..'s and all. If you just want the footer sitting in one place, you could say <!--#include virtual="/footer"-->, where virtual is looking at the absolute path. So for a footer for me, on this machine, I'd have to say virtual="/~dylan/footer", as absolute paths look right to your server's root directory. Is this confusing you? Try scouring the web, or asking your local webmaster for pointers.

You can do headers, too! Do all your pages have the same <body> tags? why not make a file called body, and you end up typing less! There are googles of ways that you can include bits of files into your HTML documents; experiment and have fun!
Dylan Humphrey
Swarthmore College Class of 1998
Even More!

I learned this all from other sources; here they are, along with some others that might be helpful. I'm sure you'll agree with Aaron Benoy when he says, "server-side includes... is there *anything* they can't do?"

I hope you found this page to be interesting and/or helpful! Seeya later, and enjoy your web weaving!!

Dylan Humphrey
Swarthmore College Class of 1998