A modular static site generator in Python
Project description
Markupdown
Markupdown is a dead-simple static site generator. You write a build.py file that calls Markupdown commands and run it. Here's what a build.py file looks like:
#!/usr/bin/env python3
from markupdown import *
# Copy files to the site directory
cp("assets/css/*.css", "site/css")
cp("assets/js/*.js", "site/js")
cp("assets/images/*.[jpg|jpeg|png]", "site/images")
cp("*.ico", "site")
cp("pages/**/*.md", "site")
# Update markdown frontmatter
title("site/**/*.md")
siblings("site/**/index.md")
children("site/**/index.md")
changelog("site/**/*.md")
transform("site/**/*.md", lambda md, _: md.frontmatter().pop("source", None))
# Render pages
render("site/**/*.md", site={"title": "My Site"})
Commands like title and index just scan a directory to create, update, or delete markdown files. title, for example, adds a title field to each matching markdown file's frontmatter.
Commands
Markupdown ships with the following commands:
changelog: Updates thecreated_at,updated_at, andchange_logfields in markdown frontmattercp: Copies files to the site directorytransform: Applies a transformation function to the frontmatter in markdown filessiblings: Generatessiblingsfrontmatter for sibling markdown fileschildren: Generateschildrenfrontmatter for child directories with index.md filesinit: Initializes a new sitels: Lists files in the site directoryrender: Renders the markdown using liquid templatesserve: Starts a local HTTP server to view the sitetitle: Updates thetitlefield in the markdown frontmatterfeed: Generates an RSS and Atom feeds
I'll probably add more (e.g. sitemap, minify, social). It's a work in progress.
Installation
pip install markupdown
Markupdown is compatible with Python 3.10 to 3.12
Usage
After you install Markupdown, go to an empty directory and initialize it:
python -m markupdown init
This will create a scaffolding with files and directories like this:
.
├── css
│ └── style.css
├── img
│ └── image.png
├── pages
│ ├── index.md
│ └── posts
│ ├── index.md
│ ├── post1.md
│ └── post2.md
├── templates
│ ├── _footer_.liquid
│ ├── _head_.liquid
│ ├── _header_.liquid
│ ├── _pages_.liquid
│ └── default.liquid
├── .gitignore
└── build.py
Run ./build.py to generate your site. The output will be in the site directory.
Markupdown comes with a server you can start with:
python -m markupdown serve
Open http://localhost:8000. You should see a (rather ugly) stub site.
You can clean your site directory with:
python -m markupdown clean
Philosophy
Markupdown is designed to be pretty dumb. It's just a collection of functions that help you do three things:
- Stage your
sitedirectory with markdown, css, js, images, and so forth (usingcp) - Transform the files in
siteto add metadata or create new files (usingtitle,index,nav, etc.) - Render the markdown using liquid templates (using
render)
That's it. Stupid simple. Worse is better.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markupdown-0.2.3.tar.gz.
File metadata
- Download URL: markupdown-0.2.3.tar.gz
- Upload date:
- Size: 69.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.22.3 CPython/3.12.3 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2d6a06a9b573d4c6c953dfa78f98eec48f57804bc97d008e8bbb6cc26d395b
|
|
| MD5 |
d7362a4571a1de0f212e349fb2049051
|
|
| BLAKE2b-256 |
31fc1ebd93498d553e8c61b64771f9ca27174a2010b9c3757d3198848b6ac76f
|
File details
Details for the file markupdown-0.2.3-py3-none-any.whl.
File metadata
- Download URL: markupdown-0.2.3-py3-none-any.whl
- Upload date:
- Size: 77.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.22.3 CPython/3.12.3 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
203e0d1e9b519f319fa935c335529d8378af9f6c186a8e110d256f4056ce7e32
|
|
| MD5 |
294413eba1f935450c61b13ccb1376a3
|
|
| BLAKE2b-256 |
0d9819a7393685b2fc30f991b9d4cb83ba80c01826496a3d6eebdaf3c4335629
|