Webmaster Time Savers – Using Includes

Posted in Web Programming | By LGR | On March 21st, 2007

Perhaps the biggest time saver that every webmaster should take advantage of is using includes on their website. By taking the common sections of code of your website and placing those sections of code into include files you will be able to make your website easy to manage and maintain.

There are many different types of includes. If your web host is using Apache you should be able to use a simple Apache include. A common Apache include looks like this: <!–#include virtual="header.html"–>

If you have access to PHP the same include would be like this: <?php include(‘header.html’); ?>

If you are on a Windows server and can use Active Server Pages you can use an include like this: <!– #include file=header.asp –>

I have seen many different combinations of includes. Personally I like to use PHP or ASP includes depending on what the server supports. The reason to use a PHP or ASP includes is because you can use the entire header/footer portion of a web page. PHP and ASP includes process the pages that they include which means you can do simple variable substitution to change the title and other meta information of a page. This also means each page only has the content for that page with very clean HTML. The following is a simple example:

<?php
$title="Website Title";
$description="The description for this page.";
$keywords="keyword, keyword";

include(‘header.php’);
?>
<h1>Page Heading</h1>
<p>Web page content. This can be all kinds of information including text, images, flash and more.</p>

<?php
include(‘footer.php’);
?>

By using includes webmasters can dramatically decrease the time it takes to create and maintain a website. If you are building your own website learn how to use includes it will allow you to focus on creating content for your website, instead of constantly copying repetitive HTML. If you are having a website built for you ask your developer if they plan on using includes to build your website, so you get the most value for your money.

Similar Posts:

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • email
  • FriendFeed
  • Reddit
  • RSS
  • Twitter

Leave a Reply

COMMENT


My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
  • Great debate, ideas, criticism and colorful commentary is always appreciated and approved!
«
»