[./home]

Simple Stupid Static Site Generator in Python

Yes, this is yet another static site generator.
I use raw python template and markdown syntax with little tweaking.
It has been inspired by this post on Hacker News.

Look at gen.py for details.
I try to keep it simple stupid.

Principles are:

Configuration

Front Matter metadata

Activation of publication

Only .md files with activated publication are generated in the target directory hierarchy.

---
published: yes
---

Custom templage

With the following metadata gen.py will use _template\my_template.html instead of _template\default.html

---
template: my_template
---

PHP generation

As an alternative to the default .html file generation, it is possible to generate a .php file.

---
extension: php
---

Having a php extension allows to include raw php code through oneliner comments. For example:

<!-- gen.py: include 'citation.php'; -->

will put

<?php include 'citation.php' ?>

in the php output file.

This is how the dynamic citation of the main index page is done and the citation.php file contains something like:

<div id="citation">
<?php
    $json_str = file_get_contents('citations.json');
    $arr = json_decode($json_str);
    $entry_id = random_int(0, count($arr)-1);
    echo $arr[$entry_id];
?>
</div>

Python dependencies

For converting markdown .md files to .html I use markdown it py with core plugins (mdit-py-plugins).

Install it using the pip install markdown-it-py[plugins] command.