Static Jinja2 Site Generator

2017-10-21

I recently rewrote my website using staticjinja, a static site generator. This is what my website looks like and here is the source code. The features / setup-instructions are described below.

Description

  • It is a static site, based on staticjinja.

  • Content is written in HTML or markdown, and served as HTML5 files with an (almost) vanilla bootstrap layout.

  • Your file directory structure is preserved. Binary files are directly copied, and the rest are passed through Jinja2.

Source code

I use a heavily customized build script (available here) to provide the following:

  • Render markdown with lots of extensions (MathJax, wikilinks, breadcrumbs, etc.).

  • Allow using Jinja2 templates in markdown.

  • Provide globbing functions (accessible via Jinja2) to display lists of files.

  • Use a YAML site configuration file

  • Only render files based on modification times for speed (configurable).

Setup Instructions

  • To download use

    git clone --recursive https://gitlab.com/gi1242/sjinja-www.git
    

    (Don’t forget --recursive, otherwise you will have to run git submodule update --init to update the submodules.)

  • Edit site.cfg and put in your URL / defaults.

  • Generate the site by running build.py. Use build.py -h for options. Pass regexps on the command line to force re-rendering of certain files.

Editing instructions

  • Generic Markdown syntax can be found here.

  • Site specific markdown extensions and macros can be found here.

  • The current layout and structure is described here. (You can ignore this if you plan to just write in Markdown, or want to create your own layouts from scratch.)

Bugs

  • 2017-10-21: Continuously watching for changes with -w isn’t perfect. Any file you change is always re-rendered, but the dependencies and changes to meta-data are ignored. I’m not interested in fixing this. Re-running the build script (without -w) renders everything correctly.

📮 Leave a comment (Spammers beware: All comments are moderated)

Sorry. There was an error submitting your comment. Please try again, or contact me if the problem persists.
Sending comment; please wait.
Thanks. Your comment was successfully submitted. It will appear here shortly if it isn't spam.