As a website gets bigger it can become
more difficult and time consuming to maintain. One way to help
manage this is with the use of include files. Using includes will
cut down on time by limiting the amount of code or html you will
have to add to new pages or time spent updating existing pages.
Include files allow you to take pieces of redundant code or html and
place them on a page by themselves. This is practical approach in
keeping maintenance down to a minimum in a variety of ways. Below
will give you an idea of what to use them for.
These are just some of the scenarios in which an include file could be
beneficial. All it takes is one line to include a file on a page.
For example, we have a bunch of info we want on all our pages
that may need to change from time to time. First we will create a
page named stuff.asp and put all that information on it. Now we put
that in a directory we will call include. Now on every page where
we want this information to be displayed we simply add this line:
<!-- #Include Virtual="include/stuff.asp" -->
By using Include Virtual as opposed to Include File, The server
knows to look in the root of the web for the described path. If we
use Include File then the server follows the path in the directory
in which the page calling it is in. This would result in disaster as
the file would not be there. The client would get a nasty little
message in the browser instead of the page and you would wind up
looking like you don't have a clue what you're doing.
That's it. Now when we want to edit this we just open stuff.asp, make the change and voila, all the pages
on your web site are updated in no time!
Anytime you have a portion of your pages that is global in nature
and subject to frequent changes or updates an include file would be
a prudent way to address the situation.
The pages on this site all use includes. Both of the banners on
this page are in separate includes. The footer at the bottom, and
the entire menu to the left are includes as well. This allows me to
make global changes by just editing one file.