Qinglin's blog

Home Photos Writings Others

flea: A Minimal Static Site Generator

2025-07-31

For the following reasons, I decided to write this detailed documentation in a casual style close to a personal memo:

Introduction

flea is a tool that reads structured Markdown files with frontmatter metadata and generates a static website.

flea uses no configuration files and no JavaScript. The writing area contains only Markdown; the output area contains only HTML and CSS (plus a flea icon from Icons8).

flea.py depends on two libraries: mistune and python-frontmatter:

pip3 install mistune python-frontmatter

It accepts only one argument: the project directory path:

python3 flea.py /path/to/project

⚠️ Note:

Directory Structure

flea reads a specific directory structure. Here is an example:

my-blog/
└── content/                            # required
    ├── index.md                        # required – site metadata & homepage
    ├── travel/                         # category
    │   ├── index.md                    # optional – category intro, no metadata
    │   ├── a-trip-to-kyoto.md          # normal post
    │   └── why-i-love-nyc.md
    ├── recipes/
    │   ├── easy-sandwich.md
    │   └── quick-pasta.md
    └── drafts/                         # optional – drafts
        └── soy-sauce-noodles.md

⚠️ Note:

Configuration and Metadata

flea uses frontmatter format to store metadata inside Markdown files:

Here is an example content/index.md:

---
lang: en-US
title: Jane's Blog
author: Jane Doe
nav:
  - Home: /
  - Travel: /travel
  - Recipes: /recipes
footer: Generated by flea
---

Hi! This is my new blog...

All five fields above are optional:

Here is an example of a normal post:

---
title: Why I Love NYC
date: 2025-07-30
---

My first time in New York City was during a winter...

These two fields are mandatory; date must use ISO format YYYY-MM-DD.

⚠️ Note:

Markdown Syntax

flea supports only the following Markdown syntaxes:

flea uses a custom syntax for images:

![class](src=https://example.jpg "title")

It renders as:

<img src="https://example.jpg" alt="title" title="title" class="class" />

Depending on the class, flea’s default CSS supports one default style and three special renderings:

⚠️ Note: