Package released on npm: https://www.npmjs.com/package/zenmd
The simplest way to transform a directory of .md files into a static site.
- https://idealistspace.com/zenmd - here is a post (about why ZenMD was built) on a site that's built with ZenMD. It's meta... :)
- https://thezenjournal.com - a Remix custom homepage with a ZenMD compiled
posts/directory
Just one command to build and another to deploy:
- Generate site
npx zenmd <inputFolder> --output <outputFolder or default: ./dist>
# Or if you prefer to install to a global command:
npm install zenmd -g
zenmd ...- Drag and drop the generated folder into Netlify
- Or
netlify deploy
zenmd preview ./docs # also support other args as main command like --layoutThe preview server rebuilds on file changes and serves clean URLs without the
.html extension.
- Bring your own editor and host. Obsidian, Bear, Typora, VS Code... Netlify, Vercel, Cloudflare...
- Publish your Obsidian digital garden.
- Back to the future: edit .html layouts without compiling.
- Bring your own framework, and let ZenMD render your
.mdfiles.
- Simplicity First: Transform your markdown files into a clean, minimalistic static site with a single
npxcommand. - Convention over Configuration: Focus on your content while ZenMD handles the technical details, making smart defaults that work out of the box.
- Transform .md to html
-
GFM markdown, with all the features supported by remark-gfm.
- That includes table, footnotes, even raw html tags, e.g.: iframe for embeds.
-
Support images in markdown files.
- Includes Obsidian-style image syntax
![[image-path.png]]with smart path resolution: searches current directory first, then recursively through subdirectories. - Image attributes: Decorate images with custom attributes using
{#id .class key=value}syntaxThis allows you to add:{#main-hero .bleed .rounded width=1200 height=600} {.center width=150 height=150}
- IDs:
{#hero-image}→<img id="hero-image"> - Classes:
{.bleed .rounded}→<img class="bleed rounded"> - Dimensions:
{width=320 height=240}→<img width="320" height="240"> - Data attributes:
{data-loading="lazy"}→<img data-loading="lazy"> - Any HTML attributes supported by
<img>tags
- IDs:
- Includes Obsidian-style image syntax
-
Built-in image lightbox: click any image to open it in an overlay.
-
Wiki links:
[[Another Page]] => [Another Page](/another-page.html)by default. Use--clean-link(-c) to skip the.htmlsuffix. -
Auto header anchor links, so you can navigate to any H2-h5 headers directly.
-
Table of contents generation when a
## Table of contentsor## Contentssection is present. Renders a side TOC when the viewport has enough horizontal space. -
Support raw html in markdown
-
- Custom html Layout support (any layout.html files at the same level or above will be used, if none found, default layout will be used.)
- Layout option via
--layoutto select a built-in theme (currentlydefault,matrixorcyberpunk) when no custom layout.html is provided.- Support layout ejection, so you can customize the layout:
zenmd eject --layout <default|matrix|cyberpunk>. This will create alayout.htmlin current directory.
- Support layout ejection, so you can customize the layout:
- Live preview server with rebuilds:
zenmd preview <inputFolder> - Filter docs with matching tags
--tags=publish:truewhich will only build files withpublishflag or--tags=draft:falsewhich will not build files withdraftflag. - Automatically infer title from first H1
- Optional
site.yamllets you define global front matter defaults (e.g. title, description, favicon) that individual pages can override. - Generates
sitemap.jsonat the output directory with a navigable tree (title, dates, tags, order).- Ordering uses
nav_order,navOrder,nav-order, ororderfront matter (lower comes first).
- Ordering uses
- Generates
sitemap.xmlwhen a base URL is available.- Requires
baseUrloption orBASE_URLenv var, sincesitemap.xmlrequires full URL. - If missing base url, no
sitemap.xmlwill be generated.
- Requires
- Generates an
rss.xmlfeed of the most recent pages when a base URL is available.- Configure the feed (and exclude folders from it) via the
rssblock insite.yaml, see RSS feed.
- Configure the feed (and exclude folders from it) via the
- Optional site navigation sidebar for built-in layouts, powered by
sitemap.json.- Enable via
site_navigation: truein front matter orsite.yaml.
- Enable via
- Automatically generates
robots.txt - Auto-discovers favicons from your content folder, copying
favicon.*to the output (with a built-in fallback when none is provided).
-
Global defaults with
site.yaml: Place an optionalsite.yamlbeside your Markdown files. Keys underfront_matterbehave like page-level front matter and are merged into every document (page front matter still wins). Runzenmd ejectto scaffold both a layout and an examplesite.yaml. -
Favicon resolution order:
- Page/front matter
faviconvalue (merged fromsite.yamlor the Markdown file). favicon.*in the input folder root.favicon.*insideinput/assets/.- Built-in fallback (
favicon.png).
When a
baseUrlis supplied, ZenMD prefixes the resolved favicon path so templates can reference it with{{favicon}}. - Page/front matter
-
OG image resolution order:
- Page/front matter
ogImagevalue (from the Markdown file). - First image found in the Markdown content.
- Site-wide
front_matter.ogImagefromsite.yaml. - Built-in fallback (
og_image.png).
- Page/front matter
-
Image handling:
- Absolute URLs (e.g.,
https://example.com/image.png) are used as-is without copying. - Relative URLs are copied to the output folder (preserving the path relative to the input file).
- When
baseUrlis provided, relative paths are prefixed with the base URL in theog:imagemeta tag. - Without
baseUrl, relative paths are rendered as-is (e.g.,./image.png).
- Absolute URLs (e.g.,
-
OG URL (
og:url) generation:- When
baseUrlis provided, ZenMD generates the full canonical URL for each page. - The URL is constructed as
baseUrl + output pathwithout the.htmlextension. - For
index.htmlpages, a trailing slash is used instead. - When
baseUrlis not provided, theog:urlmeta tag is omitted.
- When
-
Built-in templates: All built-in layouts (
default,matrix,cyberpunk) include OpenGraph meta tags forog:title,og:description,og:image, andog:url.
When a base URL is available (--baseUrl or the BASE_URL env var), ZenMD writes an RSS 2.0 feed to rss.xml in the output folder and the built-in layouts advertise it with a <link rel="alternate" type="application/rss+xml"> tag. Custom layouts can do the same with {{{rssUrl}}} and {{rssTitle}}.
- Every rendered page except the homepage (
index.mdat the root) is a candidate. - Items are sorted by
createdAtfront matter, newest first, and capped atlimit. Pages withoutcreatedAtcome last and have nopubDate, so add it to anything you want ordered properly. - Each item carries the page title, link,
pubDate, tags as categories, the front matterdescription(or the first paragraph when there is none) and the full page HTML with links and images rewritten to absolute URLs.
Tune it with an optional rss block in site.yaml; every key is optional:
rss:
enabled: true # set to false to skip the feed entirely
title: "My Awesome Site" # defaults to front_matter.title
description: "Recent posts" # defaults to front_matter.description
language: "en"
limit: 20 # number of most recent pages to include
exclude: # paths relative to the input folder
- drafts # everything under drafts/
- about.md # a single page
- "**/archive" # glob patterns (minimatch) work tooexclude only affects the feed; excluded pages are still built and still appear in the sitemap. Use --tags if you want to keep pages out of the site altogether.
No known deal breakers at the moment.
Feel free to create an issue or submit a PR on Github if you notice any...
- Hugo/jekyll and traditional SSG: no need to download a framework or generate a framework specific repo, your content (and npx) is all you need.
- Blog starter kits: less customization, simpler setup, no git repo with a dozen configs mixed with your content. No React components.
- Notion/Obsidian Publish: these are simpler solutions (no git/CLI) from bigger org and more integrated to your workflow if you use these tools heavily. ZenMD is a balance between independence and simplicity.
- Built with remark
- Table of contents powered by remark-toc
- Default theme used SimpleCss
- Alternatives: markdown-styles, remark-cli, MkDocs
Made by randomor, who also made ZenJournal
- Publish:
npm publish --access public
ZenMD is open-source software licensed under the MIT license.