TheIndpendentPublisher.com
Blog Set Up Build Run About
 »  Build Home
 1. Basic Tools
 2. Advanced Tools
    · Content management
    · Style sheets
    · Server includes
 3. Usability
 4. Design



Powered by Google

You are here: Home > Build > Advanced Tools > Server includes

Using server-side includes on your site

Before we get into the nitty-gritty of server-side includes (SSI), you should know that this feature often incurs additional expense. As the name suggests, server-side includes work through your Web server. If you don't run your own Web server, you'll have to talk to your hosting provider to see if they offer SSI capability. Most of the time, implementing SSI requires an upgrade to a slightly more expensive hosting account.

With that caveat out of the way, let's dive in. SSI is a powerful tool that's driven by two things: A file and a piece of code. The file is a simple document that lives on your Web server. The piece of code is an element that's added into an HTML document. When someone visits a page on your site, the piece of code in the HTML document "calls" for the file on the server. As the browser displays your page, the information in the server file is automatically inserted into the HTML document. When the page has finished loading, all the elements are arranged in their normal fashion. The user is unaware of the server-side includes because the entire process happens behind the scenes.

So, besides displaying content in a tricky way, what's the point of includes? The two major benefits are tidiness and management.

Tidiness

Let's use an example from this site. At the top of this page you'll find four navigation tabs: Home, Set Up, Build, and Run. These four tabs are built with HTML -- a lot of HTML -- and the code for the tabs takes up quite a bit of room in an HTML document. Now suppose a typo was found in this page's text and the editor needed to go into the document and fix it. Upon opening the document, the editor would be confronted by a long page of HTML tags that are used by the navigation tabs. These tags are integral to the site, but when it comes to maintaining and tweaking the content, they're an obstacle.

Fortunately, this obstacle doesn't actually exist because the site is built with includes. When this page was created, the code for the navigation tabs was inserted into an include file, so when the editor opens the HTML document, the code used by the tabs doesn't appear. Because of this, tweaking the content-- and finding that typo -- is much easier.

Management

Continuing the previous example, let's say the editor wants to change the name of the Home navigation tab. He or she feels "Index" is more appropriate (he or she would be wrong, but that's another matter). If the navigation tabs were coded into every page of the site, the editor would have to manually edit every page of the site. This is an arduous, eye-bleeding process. Thankfully, the navigation tabs were built as include files, so making the change requires only a few alterations to a few files. Once the changes have been made to the includes, the Home tab will now be known as the Index tab across the entire site.

Related links

Name Type Notes
Introduction to Server-Side Includes Tutorial This tutorial from Vortex Design shows you how to test your server for SSI compatibility.

Got a recommendation?
Send it to: editor@theindependentpublisher.com.

© 2000-2006, The Fodder Network. All rights reserved. Don't steal our stuff.