Treeplate
Treeplate is a set of xslt scripts for generating static websites. Authors write xhtml content by hand and provide a description of the site hierarchy. Treeplate generates the site, automatically fitting the content into boilerplate xhtml for
- headers, including stylesheet, icon, and relation links,
- footers, including author and last changed date,
- a hierarchical menu bar without scripting, like the one at left, and,
- a sitemap file for search engines.
Treeplate also adds alternating class attributes to table
rows—class="row0"
, class="row1"
—so that they can
be coloured by a stylesheet if desired.
There is an import feature for inserting generated content, like, for
example, this manual page, and a feature for
adding footnotes.1
The boilerplate generation makes it easy to experiment with specialized
support for troublesome browser software without having to manually edit
all pages.
Similarly, site redesigns may only require changes to the stylesheet and
automatically-generated elements.
If your (planned) website is predominantly static and you prefer to create it in a text editor but you want to avoid the tedium of copy-paste-modify for the common bits, then Treeplate could be for you!
This website was generated by Treeplate.
Download
Treeplate is released under a BSD license. It may be used and modified without restriction but no guarantees or support are offered. Nevertheless, patches, problem reports, and suggestions for improvement (in keeping with the minimalist philosophy) are welcomed.
The current version is available for download: Treeplate 1.2.2 (20090422). It is intended for unix systems and requires a Bourne shell and xsltproc. It should also work with other xslt processors and only requires xslt 1.0, xpath 1.0, and the exsl:document extension.
The source code is kept at git@github.com:tbrk/treeplate.git.
Operation
Treeplate requires these files and directories:
src | Contains sitetree.xml and the content sitepage files. |
dst | Must replicate the directory structure of src .
Contains any non-generated files, such as css style sheets, images, and
pdf documents. |
xsltsrc | Contains the xslt scripts; makepage.xsl can be modified
to change the boilerplate. |
makesite.sh | This simple shell script transforms xml files in src
into html files in dst . |
The sitetree.xml file
The sitetree.xml
file describes the hierarchical structure
of a site.
An edited extract from this website is:
<!DOCTYPE sitetree SYSTEM "sitetree.dtd"> <sitetree> <rooturl>http://www.tbrk.org</rooturl> <prefix>Timothy Bourke - </prefix> <style>basic.css</style> <icon>favicon.ico</style> <item homelink="yes" priority="1.0"> <name>Home</name> <file>index</file> <item directory="papers"> <name>Papers</name> <file>abstracts</file> </item> <item changefreq="yearly"> <name>Address</name> <file>mail</file> </item> </item> <item directory="software"> <name>Software</name> <file>index</name> <item>Treeplate</name> <file>treeplate</file> </item> </sitetree>
Two hierarchies are described: that of items as presented to visitors, and
that of the organisation on disk.
The latter may be simpler than the former and is expressed by the
item
directory
attributes.
The full list of item attributes is:
directory |
describes how the files are stored on disk. |
inmenu |
if "no" the item is excluded from the navigation
menu. |
homelink |
"yes" marks the home page (for relation links). |
sitemap |
if "no" the item is excluded from
sitemap.xml . |
changefreq |
inserted directly into sitemap.xml . |
Each item may contain other items, and must contain two elements:
name |
Text used in titles and menus. |
file |
Root name for the the source .xml and
destination .html files.
An optional extension attribute allows the destination file
extension to be changed.
An optional url attribute allows menu items to be directed
elsewhere; a destination page is still generated.
An optional rellinkprefix attribute is prefixed to relative
site links from the generated page, which is occasionally useful for
accounting for the url attribute's effects. |
Several settings can be set by adding the elements below to an
item
, or to the sitetree
itself,
they are inherited by that branch of the hierarchy:
prefix |
Text inserted into the page title. |
suffix |
Text inserted into the page title. |
author |
Author name, with href attribute. |
style |
Filename of a css stylesheet. |
script |
Optional script which may contain a src
attribute containing the url of a script file. |
icon |
Filename of a page icon. |
link |
Additional relation links, for instance for copyright
and content , specified in a rel attribute; the
element must contain a url. |
keyword |
Multiple keywords can be specified, they are not inherited if the
attribute inherit is "no" .
Non-inherited keywords can also be specified in the page source files. |
The root sitetree
element must contain rooturl
,
which is required to generate sitemap.xml
.
All other generated links are relative.
The source files
The source file for this page resembles:
<!DOCTYPE sitepage SYSTEM "sitepage.dtd"> <sitepage> <title>Treeplate</title> <description>Xslt scripts for generating a static website.</description> <lastmod>$LastChangedDate: 2008-06-06 12:50:53 +1000 (Fri, 06 Jun 2008) $</lastmod> <keyword>xslt</keyword><keyword>xhtml</keyword> <content> <h1>Treeplate</h1> <p>Treeplate is a set of xslt scripts for generating static websites. ... </content> </sitepage>
The list of all possible sitepage
elements:
title |
The page title.
An inherited prefix or suffix can be ignored with, respectively, the
attributes prefix="no" and suffix="no" . |
description |
The page description. |
lastmod |
The last modified date for insertion into the footer. The $ signs, from subversion tags, are removed if present. |
keyword |
Associated keyword.
Multiple keyword elements may be given.
They are combined with the inherited keywords. |
author |
Overrides the inherited author attribute.
An href attribute must be given. |
prepage |
Optional text for insertion before the opening html
element. |
header |
Optional additional elements for insertion into the destination
head .
An optional charset attribute allows a charset other
than UTF-8 to be specified. |
style |
Optional filename of a page-specific css stylesheet. |
script |
Optional page-specific script. It may contain a src
attribute containing the url of a script file. |
navbar |
Optionally construct a navigation bar on each page using the given
text as the first label. A class attribute is permitted. |
content |
Xhtml content for insertion into the generated page.
|
postpage |
Optional text for insertion after the closing html
element. |
Sometimes links change when a website is rearranged.
Redirection pages can be generated by giving title
and
redirect
elements only.
The latter must have a single href
attribute containing the
updated url.
Validation
Document Type Definitions are provided for the sitetree and
sitepage files, they rely on the modular
xhtml 1.0 definitions,
but validation is disabled in makesite.sh
by default.
It can be enabled by removing the --novalid
option from the
call to xsltproc
.