Say you had a 20 page website with the same layout and navigation on every page. Every time you wanted to change the layout or the navigation, you'd need to edit all 20 pages to match. What a chore!
If your server supports either PHP or SSI, there is a much easier way.
Create two text files, one called "header.txt," the other called "footer.txt". In those files, place the header and footer code from one of your HTML pages. Here are some examples:
|
|
Then, go through your pages, and replace the HTML headers and footers with this:
<?php include('header.txt'); ?>
This is where the main body of content would go.<p>
It can contain HTML code, just like a regular page.
<?php include('footer.txt'); ?>
And rename them to .php files rather than .htm or .html. Now you only have to edit the header and footer files, and all your pages will reflect the changes!Note: If all your files are in the same directory, you can just link to 'header.txt', but if you have several directories, be sure to change the location to point to the file, eg: '../header.txt'.
You can do the same thing with SSI, if your server doesn't support PHP. Instead of using the <?php include ?> code, use the following code:
<!--#include file="header.txt" --> This is where the main body of content would go.<p> It can contain HTML code, just like a regular page. <!--#include file="footer.txt" -->And rename the files from .html to .shtml, so that the server knows the file includes SSI. Note that there is no space after the <!-- but there is one before the -->, that is important.
That's it!
Can't find what you're looking for? Try searching for it:
© 2000-2008 Xentrik.Net