Thot - the static site generator
Info: | See github for the latest source. |
---|---|
Author: | W-Mark Kubacki <wmark@hurrikane.de> |
Derived from Arthur Kozielâs pyll.
About
With Thot you can write your sites, documentation or even your blog with your favourite text editor and then have everything rendered to static files.
Thot understands Markdown, RST, Creole and Tracâs markup for your content. You can still write everything as plaintext or HTML as well if you like. For templating (embedding your content into a design) you can chose between Mako and Jinja2.
The nice thing about Thot is that you can replace almost everything by your own plugins easily.
Some blogs powered by Thot:
License
Licensed under the Reciprocal Public License, Version 1.5 (http://www.opensource.org/licenses/rpl1.5).
⊠which means you can use it as-is even for commercial purposes, free of charge, as long as you notify me about any modifications youâve made along with a patch with them. And yes, of course, your templates are not covered by that â though I hereby kindly ask you to add/leave the âmeta-generator: Thotâ entry in your HTMLâs HEAD for statistical purposes.
Usage
Quickstart
Run thot --quickstart mysite
to have directory âmysiteâ created with a basic site
skeleton. You will be asked a series of questions regarding default values for authorâs name
and such by that script. Your answers will result in file _lib/settings.cfg
.
quickstart
obeys the optional parameter -t <shortname>, with âshortnameâ being
the shortname for a recognized templating engine: mako or jinja2, Mako being preferred.
Run thot
to generate a site. The command looks for files with extensions .htm/.html,
.xml, .rst and .md/.markdown; parses them and passes the results to your template(s).
â âParsingâ means transforming the markup (for example Markdown or RST) to HTML. â
Directories and files that start with a dot or an underscore will be ignored,
everything else (i.e. images) will be copied. The the results will be available
in â_outputâ.
Basics
Your templates go into the â_templatesâ directory of your site. Every page has a template, either âselfâ (thus none, i.e. for XML, RSS or Atom feeds) or any of your own liking determined by âtemplate:â keyword.
Every page consists of one âheaderâ (with keywords) and one âcontentâ section, in that order. It looks like this:
title: Hello World template: post.mak category: article tags: [static blog, CDN, like Jekyll] This is the content. Hello World!
The header is formatted in YAML. You can access it from within the content by variable âpageâ. With Mako by ${ page['title'] } or Jinja2 by {{ page.title }} for example.
Content can be anything, from plaintext over html to markup, which is determined by the file extension. Although the content will be subject to rendering by the templating engine of your choice, you are free to abstain from using it.
Default settings can be found in â_lib/settings.cfgâ, which is parsed as YAML.
Reference
Headers
This list is not complete, but you can use the following keywords. At least âtitleâ has to be set:
- title
- The pageâs title. Used within HTMLâs <title>.
- status
- Recognized are âhiddenâ, âdraftâ and âliveâ. The latter being assumed if you didnât set anything. Status âhiddenâ prevents pages from being listed in index-pages - which makes sense for the index pages (contents, archiveâŠ) itself.
- date
- Creation date â and optionally time â of the page. If missing, the âctimeâ of the pageâs file is used.
If the date is in the future, the page wonât be published [1] before that (say âscheduledâ),
sparing you the embarrassment of leaking something prematurely. (Like a Fortune 500
company once did, announcing a product on their homepage before their CEO held the presentation. Ouch.)
Your (default) timezone is taken into account.
Format is ISO-8691,
yyyy-MM-dd
such as in2011-09-07
oryyyy-MM-dd HH:mm:ss
. - timezone
- Set this if you want to overwrite your default timezone for that page. Must be anything pytz recognizes, for example âUTCâ or âEurope/Berlinâ. Makes only sense if date header is set, though, and has an effect on the publishing date and RSS/Atom feed, where timezones are added to date-times. Globetrotters will like it â but if in doubt skip this entry.
- expires
- If set, Thot will skip that page after the given date (and optionally, time) excluding it from being published [1].
Headers overwrite settings found in â_lib/settings.cfgâ. You can access everything, including the header(s), using âpageâ and the vanilla settings using âsettingsâ (following is Mako and HTML5):
<article> <hgroup> <h1>${ page['title'] }</h1> <h2>how ${ settings['author']['name'] } sees it</h2> </hgroup> <time pubdate="pubdate" datetime="${ page['date'] | n,datetimeformat("%Y-%m-%dT%H:%M:%S") }"> ${ page['date'] | n,datetimeformat("%b %d") } </time> <p>${ page['content'] }</p> </article>
Category and Tags
Thot comes with two sample plugins, both in Tagging.py. They introduce some more headers:
- index
- Can be a word or list of words. If set marks an index-page for tags or categories. Donât forget to set âstatus: hiddenâ, too. For every tag or category as âfieldâ: the page will be copied, and rendered with variable âcollectionâ holding an ordered list of pages having the given âfield_valueâ â which is the actual category or tag.
- tags
- String or list of strings. Tags of the page.
- category
- String or list of strings. The pageâs category. If not set the page will be filed under âuncategorizedâ.
Plugins
Please see setup.py for all available entry points. I have made sure to include at least one plugin for every entry point as implementation example for you.
If you have a good idea for new plugins and need additional hooks for it, let me know!
Thot can take advantage of...
- LaTeX for math rendering. Needs dvipng for PNG or dvisvgm for SVG, and âutf8xâ (from dev-texlive/texlive-latexextra in Gentoo and ChromeOS). Enables RST directives âmathâ for formulas (with optional directives âlabelâ and âimage_formatâ) and âeqâ for linking to labelled formulas.
- Pyphen and Wordaxe for server-side hyphenation.
â Mark
[1] | (1, 2) âPublishedâ means being written to â_outputâ directory. |