Chapter 11. Advanced Static Web Page Techniques

In Chapter 2, we looked at some simple examples of using the Template Toolkit to generate web content. In this chapter, we will look at some more advanced techniques for building web sites and manipulating HTML page content. We will start out with a minimal setup that illustrates some useful techniques that can easily be adapted and applied to any web site. The basic system will be extended throughout the chapter as we add functionality to address more complex requirements and provide more advanced features.

The emphasis in this chapter will be on generating static HTML web content. The examples will be loosely based around the Template Toolkit web site, http://template-toolkit.org/. However, we’re not going to be looking at content of any of the individual pages in any great detail, so the subject matter is largely immaterial.

Most of the techniques demonstrated are equally applicable to web sites delivering dynamically generated content and running web applications. More generally, this chapter shows how a general-purpose presentation framework can be built using the Template Toolkit. This can then be used to apply a consistent look and feel to all pages in a site, including static HTML pages (as discussed later in this chapter) and dynamic content (described in Chapter 12).

Getting Started

A few basic tasks need to be done when starting out a project for a Template Toolkit-driven web site. The first thing is to create somewhere for ...

Get Perl Template Toolkit 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.