Why Use Htm4l?

If you manage or have created a collection of web pages, you've most likely had to face making tedious and repetitive changes in many html files. Even if you have only created a few html files by hand, you probably already know how tiring it can be to edit html.

There are many editors, editing modes, and editing macro packages that can make the job of creating html easier. While some of these appear quite good, there is a big and common problem that they do not address. This is the problem of maintaining consistency across multiple web pages, or even within a single page.

For example, if you create a set of web pages on a subject, you may want them to all have the same background, same heading style, same table layout (e.g., all with borders of width 2), same final buttons to return the reader to your homepage, etc. You can build one page and copy it to create the basic structure of the others. But what happens when you inevitably change your mind about how headings should look, or want to try another style and perhaps switch to it, or decide that all the pages would be better without that green background? Without special tools, your only choice is to edit every file by hand.

Htm4l solves the consistency problem

In addition to making it trivial to enter standard html tags, the macros provided by htm4l allow you to solve the consistency problem. When you want to change the background on each of your new set of 100 web pages, you simply edit one file and then type "make" to rebuild the entire set of html files automatically.

You can use htm4l to build tables, lists, buttons, headings, backgrounds with a consistent look and feel. By producing html using the htm4l macros, you will be able to quickly and easily change the appearance of your pages. All your pages (or any subset you like). You can use a macro to refer to image files in a directory, and then move the directory and update all your URLs to refer to the new directory with a single command. As they say in the Windows95 documentation,

"... all the things you do will now be easier and faster, and what you've always wanted to do is now possible."
except in this case it's true. Yeah, right. Htm4l will obviously not solve all your problems, but once you start using it, the power and appropriateness of this approach to generating html should be quickly apparent. Using m4 to generate html can also be the source of several potential problems of its own.

Using htm4l does not mean you have to give up other html tools. For instance, lacking an htm4l emacs mode, you can use html-helper mode, written by Nelson Minar (nelson@santafe.edu), to write .htm4l files (this is what I do, though I plan to produce an htm4l mode for emacs). Or, you can use any other tool that allows you to create html. You simply create your files as usual, including definition of and calls to m4 macros, and then post-process the result with m4.

You can also take advantage of a number of other powerful features of m4 to produce html. For example, you can produce html conditionally depending on symbols defined in your Makefile, or on the output of arbitrary UNIX shell commands. M4 gives you access to the shell, has arithmetic, and lots of other odds and ends. To get an idea of what's possible, take at look this collection of example htm4l uses.

The power and convenience of using m4 to produce html is not provided by any other macro-based html generating tool that I am aware of. The htm4l macros can save you from spending buckets of time editing raw sewage (html).


Back to the htm4l home page.
© Terry Jones (terry <AT> jon.es). Last modified: Mon Oct 2 02:22:03 CEST 2006