Server Side Includes for page reuse
Posted by webstuffscan on November 23rd, 2006
Consider the following scenarios,
1. Multiple blogs with shared content. You have couple of blogs and you want some common piece of information on all blogs(possibly on side bar, header or footer).
2. Single blog with multiple templates. You have a Movable Type installation and you want some common information across index pages and archive pages.
The commonly followed practice is to include the page fragment in all pages. This becomes a nightmare after a while. Whenever there is a change in the common page fragment you have to change all related pages.
Blogging tools such as Movable Type provides some mechanism to include other files. For example, MTInclude directive can be used to reuse page fragments. The problem with this approach is that you have to rebuild all the pages and for a large installation can take a lot of time.
The perfect solution to this problem is to use server side includes. For this your Web server must be configured for server side include (Most hosting providers enable this by default). For example in my Movable Type templates I have the following line,
...
<div id="banner">
<!--#include virtual="/navbar.html" -->
</div>
...
In the above case note the virtual attribute in the include directive. This means that navbar.html is searched from the root of your web server. Another alternative is to use file attribute.
More Resources
Using MTInclude and PHP Include
Apache Tutorial on Server Side Include
- Last page and first page on Internet?
- Installing Apache Webserver on Windows XP
- Windows home server in detail
- Windows Home Server - Now a place for all your backups
- How do I create an Icon for my Web page?
