Easy maintainable static website

A static website shall be built, where all pages use the same layout. The layout may divide a page into several regions, like: footer, header, a menu, and maybe a region for displaying news. There may be other parts which all of the pages have in common (e.g. included resources like css, ...) The goal is that information shared by all pages shall not be duplicated, as this would complicate the maintainance of the website.
2 answers

Ruby static website frameworks

Using webby (https://github.com/TwP/webby) for example you can code a web-page much like using some server based webapp framework (e.g. Ruby on Rails or Django etc.)
But webby is not server-based but generates static HTML pages for you.

Generating html pages with xslt template

Regions and parts all pages have in common should be separated from page-specific information (We will refer to the latter simply as content).
The idea is to split them up as follows:

  • create an XSL template with the basic layout of the pages,
  • and for each page a file containing only the content.

So common elements and page specific content can be maintained separatly.
Every time changes have been applied, the final HTML files can be generated via xsl transformation.

    Step by Step:
  1. Create an HTML file with the desired layout (including all regions like, footer, header, ..., menu)
  2. Create one XML file per specific page, containing the elements <root><content></content></root> and put the content between the two content tags.
  3. Now create an XSLT file (with output method xml)
  4. Add one template rule which matches /root/content, and insert the layout defined in the HTML file above
  5. Finally the content has to be inserted into the output. Add the following rule to the desired location:
    <xsl:copy-of select="/root/content/*"/>

Xalan could be used to transform the pages. Then the invokation would look like:
java -cp ./xalan/xalan.jar org.apache.xalan.xslt.Process -in content/index.xml -xsl templates/template.xslt -out index.html

Hint: Time saver: Put these calls into a makefile, so only modified pages get transformed.