Lightweight and fast CLI tool written in Rust that recursively scans a directory of Markdown files, extractcs YAML frontmatter, converts the Markdown to HTML, and generate a fully linked static website while preserving your folder structure.
- Recursive Directory Traversal: Scans deeply nested folders to find every
.mdfile. - Frontmatter Parsing: Extracts YAML metadata (Title, Date, Description) from the top of Markdown files.
- Markdown to HTML: Uses
pulldown-cmarkfor highly compliant, fast Markdown parsing. - Structure Mirroring: Automatically replicates your input directory's folder tree inside the output directory.
- HTML Templating: Wraps the generated HTML inside a standard web document structure.
You will need Rust and Cargo installed on your machine to run this project.
Clone the repository and build the project using Cargo:
git clone https://github.com/ansh3108/markdown-cli.git
cd markdown-cli
cargo build --releaseThe CLI requires two arguments: the input directory containing your Markdown files, and the output directory where you want the HTML output to be saved.
#Run via cargo:
cargo run -- ./content ./public
# Or run the compiled binary directly:
./target/release/my_ssg ./content ./publicFor the parser to work correctly, every Markdown file must include YAML frontmatter enclosed in --- at the very top of the file.
The frontmatter expects three fields: title,date, and description.
Example content/hello-world.md:
---
title: My First Rust Post
date: "2026-08-06"
description: Learning how to build a Static Site Generator
---
# Hello from Rust!
This is a paragraph of **Markdown** text.
* Here is a list item
* Here is another oneThe tool will respect your folder hirarchy. If you structure input like this:
content/
├── index.md
└── blog/
└── my-post.mdThe output will automatically generate the corresponding folders:
public/
├── index.html
└── blog/
└── my-post.htmlserde&serde_yaml: For deserializing YAML frontmatter into Rust structs.pulldown-cmark: A fast, CommonMark-compliant Markdown parser.