genhtml — Static HTML Inserts for Website Files

New: as of June 2017, genhtml now handles ".*" Mac/Unix cruft files in inserts and templates folders. This includes both ".DS_Store" Finder files, and any "._*" AppleDouble resource-fork files on non-Mac drives. Both are skipped in inserts to avoid errors, but are simply copied like other non-HTML in templates because more may pop up before publication—filter later with your zip or upload tools (e.g., ziptools).

See the new script's docstring for details. For a quick example of genhtml at work, see also the template file for the page you are viewing, and its expansion via your browser's "view source." There are also new example site-publisher master scripts here and here that use genhtml as a nested tool, and are used to publish the website you are viewing.

This Python 3.X program provides basic HTML macro functionality. It replaces keys in a folder's HTML-template files with the content of correspondingly-named insert files. The net effect automatically updates static web pages when any common content they share is changed. Among its features, this program has:

This script addresses only static content: common text that can change over time, but need not be generated on each new page request. For such content, though, this program is a simple alternative to:

This program uses and requires Python 3.X, and serves to illustrate a typical utility role for Python code. See the main script's docstring and other items below for usage details.

Code and docs:



Download/view all:

This program was last changed February 28, 2018

For more code examples, see the programs page.

[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz