Introduction to PubTal

An introduction to how PubTal works.

PubTal takes text files (containing content), one or more template files (containing the website's look and feel), and produces corresponding HTML files.

In version 1.1 of PubTal two different types of content are supported, HTMLText and Catalogues. HTMLText is the simplest type of content, and is introduced here. Catalogues are used to handle collections of content, for example to build a simple photo album, and are described later in the manual.

HTMLText content is written in plain text with a limited amount of HTML markup. This means that you can use <b> tags for bold, <a> for links, etc. in your content. The templates are written in HTML with content included using TAL. TAL is a simple template language consisting of just 7 commands, and is easy enough to pickup from the examples (see also a full description of the language).

Here's a simple example of how you can use the most basic features of PubTal. The content is simply a text file, with name-value pairs at the top, and the main body of the page after a blank line. HTML Paragraphs and <br> elements are automatically created by PubTal around the text's paragraphs and newlines. In the following example a name-value pair of "title" is defined, and two HTML paragraphs are created:

title: My first page.

This is the first paragraph.
And this is a new line in the first paragraph.

The second paragraph shows <b>bold</b> and a <a href="http://www.owlfish.com/">link</a>

The templates used by PubTal are written in TAL, the template language used in Zope. Here's an example template:

<html>
<body>
  <h1 tal:content="page/headers/title">Title</h1>
  <div tal:content="structure page/content">Body</div>
  <p>Last modified: <b tal:replace="page/lastModifiedDate">Date</b></p>
</body>

The contents of the H1 heading will be the title taken from the 'title:' line of the text file, with the main content appearing in the DIV element. The header line 'title' is just an example; multiple headers can be used with any name and referenced in the template in the same way. This is the resulting HTML file.

By separating content from HTML templates in this fashion, adding and maintaining web pages becomes very easy. When you feel like using a fresh new design, you can easily modify the template and then regenerate the pages with a single command. Multiple templates can be used, and parts of templates can be shared between them. Default name-value pairs (accessed through the "page/headers/name" path) can be set, and all configuration is inherited down through the directory structure.

There's more detail on how to write templates, and how PubTal can be configured. The easiest way to learn PubTal is to start with the examples included in the download.

PubTal Version 1.1