Title: ht2html.py: A web page template processor

ht2html.py: A web page template processor

HTML frames are cool in theory, but have severe practical problems. The biggest problem with them is that they totally break navigation, especially when you end up at a frame page not through the frameset HTML. Bookmarks are also more difficult when using frames.

So the brothers Van Rossum designed the current python.org web site to use HTML tables, providing much of the benefit of a frames oriented table of contents, without the hassles. Naturally, Guido had to write a Python script to generate the python.org style, which was really cool, except he probably didn't figure that other people would want to generate web pages using slightly modified versions of that style.

Guido's script wasn't easily extensible or modifiable, so Andrew Kuchling did another implementation based on Zope Corporation's DocumentTemplate. I (Barry Warsaw) couldn't grok Andrew's script -- which says much more about me than his code -- so I did what any self-respecting hacker would do. I reinvented a third wheel. Hey, at least this time I mostly understand how it works. Since then, lots of other folks have contributed to the code, most notably including Fred Drake's work on CSS support.

This script is called ht2html because it generates .html files from .ht template files. The format of these .ht files is essentially normal HTML, with a set of optional RFC 2822-like headers at the top of the file. These headers specify certain options that ht2html's various classes support. You must include at least one blank line between the last header and the start of the body HTML.

Read about the components of a web page, how to work with stylesheets with ht2html, the docstring containing usage information, and see some examples of how to set up your own site generators. Of course, these pages are also created by using ht2html and you can see the files used as input sources:

Note: Python 2.0 or newer is required!