Page Templates

So far, you’ve seen how you can put the same content on a whole batch of pages using server-side includes. This approach is great—if your web hosting company supports server-side includes and you don’t mind the design challenges. After all, the alternative (making a separate copy of the repeated content on each page) is a surefire way to fry the last few neurons of your overworked brain.

However, web designers who own one of the two premiere web design tools—Adobe Dreamweaver and Microsoft Expression Web—have one more option. They can create a page template that sets out the structure of their site pages, and then reuse that template relentlessly. The technique is similar to server-side includes, but instead of having a web server do the work, you give the task to your web page editing program. That means you don’t need to worry about mistakes or web server compatibility. For these reasons, page templates might just be the perfect compromise for small- or medium-sized websites.

Before you get started with templates, it’s time to face a few drawbacks:

  • More time. Every time you change a page template, your web design tool needs to update all the pages that use the template. For this reason, page templates aren’t a great idea for huge websites, because the updating process takes too long.

  • More fragile. As you’ll see, the page template system is based on a few secret comments you bury in your HTML pages. Unfortunately, it’s all too easy to accidentally delete or move one ...

Get Creating a Website: The Missing Manual, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.