Static site generator
Project description
Thera
A Python script for building static HTML websites from Markdown text files, using the Mako template engine. Excellent support for blogs: allows YAML metadata in the blog markdown files, can create an Atom-compatible RSS feed.
Why use it?
- Simple: Requires one file to generate the site.
- Reliable: A static website of HTML files has almost nothing to break. Immune to the Slashdot effect.
- Secure: No database to break into. Fewer moving parts gives hackers fewer entry points into your website.
- Fast: Static pages are pre-compiled HTML, ready for display.
Minimalist design reduces maintenance headaches.
How to install it
pip3 install thera
How to use it
thera.py <markdown file(s)>
Options
-b --blog Blog index template path.
-c --config Configuration file path.
-h --help Show help.
-r --rss Blog RSS template path.
-s --static Static directory paths (javascript, css).
-t --template Page template file path.
-v --version Show version number.
YAML
YAML can be used in the markdown files:
---
Title: Hello world
Date: 09 Apr 2018 07:00 AM -0400
Slug: hello
Summary: A new blog for tech, business, and other oddments.
---
Hello. This is a new blog with a focus on tech and business.
Note: To generate an RSS feed the YAML date must include the offset from Coordinated Universal Time (UTC). In the example above, the offset is -0400
.
Template tags
Blog RSS XML page
- ${articles}: A list of page data dictionaries (explained below).
- ${now}: The current date/time in UTC.
Blog index page: a list of articles
- ${data}: A dictionary where the key is a year and the value is a list of page data dictionaries (explained below) of articles for that year.
All other pages
- ${data}: The page data dictionary with the following keys:
- content: The markdown page converted to HTML without the template applied.
- display-date: Allows the web pages to use a different date format than the YAML date.
- slug: The part of an URL identifying the page in human-friendly words. For example in https://seagrape.us/blog/space-race.html, space-race is the slug. If a slug isn't in the YAML metadata, Thera uses the markdown file name.
- summary: The summary of an article. Can be used in the RSS feed or the blog index page.
- title: The web page title. If a title isn't in the YAML metadata, Thera uses the
<h1>
header. - utc-date: The UTC version of the YAML date. Used in the RSS feed.
Configuration file
A JSON or YAML configuration file is optional:
Name | Usage |
---|---|
BUILD_DIR | Directory to store built HTML files. Default: 'build'. |
DISPLAY_DATE_FORMAT | HTML date format. Default: '%d %b %Y'. |
SOURCE_DATE_FORMAT | Markdown date format. Default: '%Y-%m-%d %H:%M %z'. |
RSS_ARTICLE_COUNT | Number of blog articles in the RSS feed. Default: 50. |
RSS_DATE_FORMAT | RSS feed date format (must conform to RFC 822). Default: '%a %d %b %Y %H:%M %Z'. |
Links
License
Contact me
Send bug reports and patches to craig@seagrape.us.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thera-4.0.tar.gz
.
File metadata
- Download URL: thera-4.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27824c0a2315771022b031f07b41321942813f773c1aada0331f2710294c7c55 |
|
MD5 | f787fdfeb2550c02b03de2d5ee99b13d |
|
BLAKE2b-256 | abdcec32aac1add222e197dacff26f1151a02332114027f148009c6f8fb99fb6 |
File details
Details for the file thera-4.0-py3-none-any.whl
.
File metadata
- Download URL: thera-4.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fe9eb490fef1df394ddbbedba24ed3272b8a58fa1e1cdbdf750b9d997d81a5b |
|
MD5 | 6b4e8083d6130d3d5690cf62b58ec1a1 |
|
BLAKE2b-256 | c5e6913cbbfcd56703370588641af3a320f79d480a49cd4a26b4b707d7063c36 |