Hajime (previously called Saisho-PY), meaning "beginning" in Japanese, is a simple, slightly opinionated static website generator built with Python.
It is the spiritual successor and replacement to Saisho (which was made in PHP), and is currently still being developed.
Get it on SourceHut, Report a Problem or Get in touch.
Important
It is important to note a few things, in case you are interested in giving Hajime a spin:
- I'm still ironing out kinks as I come across them. If you see anything, please report on Hajime tracker.
- Hajime is coded with certain assumptions, hence the opinionated part. Examples being the template files it uses, date formats or the lack of Markdown or MD extension configuration.
- As of April 19th, 2024, Hajime is not available as a standalone module, but as I use it as part of an automated build on SourceHut, it doesn't bother me. More on this later.
- Hajime is not feature complete, whatever that means in the context of minimalism. Please take this into account.
Philosophy
From my personal point of view, the biggest obstacle to writing and sharing (and well, when it comes to productivity in general) is fucking around with themes, plugins and configurations. We often go so deep into the woods while forgetting why we even went there in the first place.
The less frills and moving parts, the better. From this aspect, Hajime both is and isn't feature complete - there is one template, some frontmatter and whatever you write in Markdown format. That's pretty much it.
Hence, the idea for (or behind) Hajime, is identical to how Saisho was operating -- MD comes in, HTML comes out.
Keep it simple. Keep it honest. Keep it usable.
Dependencies and Tooling
Hajime was built with Python 3.12 in mind, albeit it probably will work with >=3.10 as well. In a gist:
- Tomli for TOML configuration.
- Click for CLI.
- Ibis for templates.
- Markdown (with some extensions). The full list of dependencies is relatively short, and can be seen here.
Usage
Installation
This is basically my build.yml
paraphrased:
- Clone https://git.sr.ht/~hxii/hajime
- Ideally install this in a venv, e.g.
cd hajime; python -m venv .venv; chmod +x .venv/bin/activate; ./.venv/bin/activate
. - Run
make install
to install dependencies.
Using Hajime
- Run
python -m hajime init
to create a default configuration file. - Put your template in
template
. - Put your content in
source
. - Run
python -m hajime build
to generate HTML files.
Templates
Hajime relies on three main files existing in the template_folder
:
list.html
- The main index or list of entries.page.html
- Entry template. Given to howibis
works, you can also have templates split to parts or have conditionals. Please see the Ibis Documentation for details.
Entries
Markdown syntax, obviously, with the following extensions:
"meta", # YAML Frontmatter
"wikilinks", # [[wikilinks]]
"extra", # Abbrev, attr and def lists, fenced code, footnotes, tables
"admonition", # rST Style admonitions - https://python-markdown.github.io/extensions/admonition/
"fenced_code", # As it says
"markdown_mark", # Marked text
"yafg", # Figures - https://pypi.org/project/yafg/
"markdown_del_ins", # Deleted and inserted text
"toc", # TOC - https://python-markdown.github.io/extensions/toc/
Hajime uses YAML frontmatter for metadata:
---
title: The page title can be different than it's name.
type: entry, page and project are supported types.
date: YYYY-MM-DD format.
tags: comma,delimited,list,of,tags
description: A text description for things like projects
---
Automating the Build
Going Forward
In the near future, I'd like to add the sync
functionality (or something similarly named) which will allow for a simpler deployment to SourceHut specifically.
Perhaps a pre-built .build.yml
file or just clear, simple instructions given how brutally simple it is to just get your content out there using SourceHut.
I currently host my blog on SourceHut, and use Hajime with the following .build.yml
to automatically re-generate and upload my website. You can take inspiration, and get a similar looking setup for your own blog.
image: alpine/edge
oauth: pages.sr.ht/PAGES:RW
packages:
- hut
- rust
- cargo
- python3
- py3-pip
sources:
- https://git.sr.ht/~hxii/hajime
environment:
site: 0xff.nu
tasks:
- setup: |
cd hajime
python -m venv .venv
chmod +x .venv/bin/activate
./.venv/bin/activate
make install
- package: |
cd $site
python -m hajime build --compress
tar -C html -cvz . > ../site.tar.gz
- upload: |
hut pages publish -d $site site.tar.gz