Markupdown
Markupdown is a collection of functions that help you build static sites with markdown.
Many static site generators are complex, rigid, and rely on plugins for extensibility. Markupdown is the opposite: it's dumb but programmable. It's kind of like a build system for static sites. A typical flow looks like this:
- Stage your
sitedirectory with markdown, CSS, Javascript, images, and so forth (usingcp) - Transform your files to add metadata to the frontmatter (using functions like
title,link,blurb, and so on) - Render the markdown with Liquid templates (using
render)
You can call Markdown's functions any way you like, but I recommend creating a little build.py file in your project root:
#!/usr/bin/env python3
from markupdown import *
# Copy files to the site directory
cp("assets/**/*.*", "site")
cp("content/**/*.md", "site")
# Update markdown frontmatter
title("site/**/*.md")
link("site/**/*.md")
blurb("site/**/*.md")
siblings("site/**/index.md")
children("site/**/index.md")
changelog("content/**/*.md", "site")
sitemap("site/**/*.md", site_url="http://example.com")
# Render site
render("site/**/*.md", site={"title": "My Site"})
# Minify site HTML, CSS, and JS
minify("site/**/*.html")
minify("site/**/*.css")
minify("site/**/*.js")
Functions
Markupdown ships with the following functions:
blurb: Updates theblurbfield in markdown frontmatter to include a brief summarychangelog: Updates thecreated_at,updated_at, andchange_logfields in markdown frontmatterchildren: Generateschildrenfrontmatter for child directories with index.md filesclean: Deletes thesitedirectorycp: Copies files to the site directoryfeed: Generates RSS and Atom feedsinit: Initializes a directory with an example sitelink: Updates thelinkfield in markdown frontmatter with the relative URL pathminify: Minifies HTML, CSS, and JSreferences: Parses markdown for hrefs and generatesreferencesandbackreferencesfrontmatter for markdown filesrender: Renders markdown using Liquid templatesserve: Starts a local HTTP server with live reload to view the sitesiblings: Generatessiblingsfrontmatter that contains paths for sibling markdown filessitemap: Generates an XML sitemaptitle: Updates thetitlefield frontmatter with the value of the first # h1 or filenametoc: Generates a table of contents from markdown filestransform: Applies a transformation function to the frontmatter in markdown files
See DOCUMENTATION.md for more information.
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:
.
├── assets
│ ├── css
│ │ └── style.css
│ ├── images
│ └── js
├── content
│ ├── 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 your new site.
You can clean your site directory with:
python -m markupdown clean
Metadata
Release files for markupdown 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| markupdown-0.2.5.tar.gz | 69.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markupdown-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 148.1 kB
Release files / markupdown-0.2.5.tar.gz
| Download URL | markupdown-0.2.5.tar.gz |
|---|---|
| Size | 69.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d985a2f1239a72d1a4b33b2833520e411437fa16d6e70a42d7c0f89e36d46aa
|
|
BLAKE2b-256 checksum How to use checksums |
d12e21aca8894622b1420da968195abf6ef50228397b575f8540f6cf7d30c691
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.22.3 CPython/3.12.3 Linux/6.8.0-1021-azure
|
Release files / markupdown-0.2.5-py3-none-any.whl
| Download URL | markupdown-0.2.5-py3-none-any.whl |
|---|---|
| Size | 78.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7027d91271630397afd82238764aa528627e8023425d07626b3da62c557102ce
|
|
BLAKE2b-256 checksum How to use checksums |
5c92e9dbdb6d90b86e830bd2e1bc031d92ec8af202b5d61bd92ed68e9fe6f675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.22.3 CPython/3.12.3 Linux/6.8.0-1021-azure
|