WWW FAQs: How do I create a template for all of my pages?

2004-08-16: for beginners and many pros, the best way to provide a consistent set of navigation links and similar content on every page is to use server side include directives. These are supported by virtually all web hosting providers, except for free hosting services, and may in some cases be allowed there.

For example, if the file navigation.html in your top-level web page folder contains navigation links, you can include it at any point in a page using this directive:

<!--#include virtual="/navigation.html"-->

Note that navigation.html should not be a full-blown HTML page with elements like <head> and <body>. Instead it should contain only the content you want to insert at that point in the layout of the pages that include it.

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!