mod_include to the rescue

Apache HOWTOs HTML/XTML Web Development

After working with content management managements for well quite awhile now, the thought of creating more than seven (more than five, less than ten) static pages for a client makes me cringe. Why? I am spoiled by using template driven solutions. With templateing, if I need to make a header change, I change it one place and I am done with it. With using static .html pages, I have to make the change to all the pages. I have grown very reliant on using find and replace, but then – because of the person I am – I have to go back and make sure everything looks right.

I am currently wrapping up a project where I was not able to use a content management system, PHP, or any sort of database. No, this is not 1998, this is present day. For decisions I will not get into, this was the situation, no getting around it. This web site has about 75 static pages and around the twentieth page I started to sweat when the client wanted a major layout change. After emailing someone technical in the department I found out they did allow the use of Server Side Includes (SSI) by way of the mod_include module in Apache. My life became much easier after this past weekend as I converted all the pages to be .shtml pages (needed for SSI). By using SSI, I was able to create common files (header, footer, side links, navigation) so any changes to the common elements, and I just need to touch one file instead of all 75 pages.

What you need to use SSI on the server end:

  • Apache with mod_include
    enabled
  • Apache configuration must have the proper AddType and AddHandlers set up: AddType text/html .shtml AddHandler server-parsed .shtml
  • Apache configuration must also have the directive set up for the appropriate directorys (): Options +Includes

What you need to use SSI on the client/page end:

  • Name all files you want to have SSI elements in them to include the .shtml extension so Apache knows to parse these files properly
  • Use the following syntax when you want to include a file: when you want to “inlcude” some common code such as a header or footer. (please see the mod_include documentation for all syntax)

Apache’s mod_includes also gives you the ability to include CGI files, show modification dates, date and time, the user name who last modified the file, etc. Lesson learned: if someone approaches you about creating a “simple” static web site, look into if SSI is an option!
[tags]Apache, mod_include, SSI[/tags]

Leave a Reply

Your email address will not be published.
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Content Management Systems Web Development

random…here and there.

Some random things to point out… Amanda Congdon is no longer the RocketBoom anchor…and just when I finally got Amy slightly hooked to this awesome vblog. Wherever she goes, I will be sure to follow. She is very talented! Diet/lifestyle update…I weighed in yesterday and actually lost a few pounds last week! That is from […]

Life

Do Not Stop on the Tracks!

I have taken the Metra (locomotive commuter train) for over seven years now and until about 5 minutes ago, had never been on a train that has hit a person or a car. This morning we hit a car and because I sit in the front car (third seat from the front) when we hit […]