A command-line tool that converts a directory of Markdown files into a beautiful, self-contained HTML documentation site — styled with Tabler UI.
- Tabler UI Design — Clean, modern interface with responsive layout
- Sidebar Navigation — Auto-generated from document headings with Bootstrap Scroll Spy
- Breadcrumb Trail — Always know your location in deeply nested documentation
- Syntax Highlighting — Code blocks rendered with the Monokai dark theme via Chroma
- Custom Site Title — Add your project name as a page title suffix (
Page - Site Name) - Multi-Language — Configurable
langattribute via-langflag - SEO Ready — Auto-generated meta description and Open Graph tags from content
- Mobile Responsive — Collapsible sidebar on small screens with hamburger toggle
- Favicon Support — Drop a
favicon.svgin your docs directory for automatic branding - Zero Dependencies at Runtime — Generates pure HTML/CSS/JS files, no build tools needed
- Directory Structure Preserved — Input directory layout is mirrored exactly in the output
# Clone and build
git clone https://github.com/wwwanghua/md2html.git
cd md2html/gen
go build -o md2html .
# Generate documentation
./md2html -in ../docs -out ../dist -title "My Project"Open dist/index.html in your browser.
git clone https://github.com/wwwanghua/md2html.git
cd md2html/gen
go build -o md2html .Requires Go 1.21+.
go install github.com/wwwanghua/md2html/gen@latestmd2html -in <markdown-dir> [-out <output-dir>] [-assets <assets-dir>] [-title <site-name>] [-lang <lang-code>]
| Flag | Default | Description |
|---|---|---|
-in |
(required) | Input directory containing markdown files |
-out |
./out |
Output directory for generated HTML |
-assets |
current dir | Directory containing css/ and js/ Tabler assets |
-title |
(empty) | Site name used as page title suffix |
-lang |
zh-CN |
HTML lang attribute for generated pages |
# Basic usage
./md2html -in ../docs
# Custom output directory
./md2html -in ../docs -out ../dist
# With site title
./md2html -in ../docs -out ../dist -title "t1yOS Developer Docs"
# Custom assets location
./md2html -in ../docs -out ../dist -assets ./tabler-dist
# English documentation
./md2html -in ../docs -out ../dist -lang en
# Japanese documentation with site title
./md2html -in ../docs -out ../dist -title "My Project" -lang jamy-docs/ out/
├── index.md -> ├── index.html
├── readme.md -> ├── readme.html
├── favicon.svg -> ├── favicon.svg
├── quick-start/ ├── quick-start/
│ └── index.md -> │ └── index.html
└── guide/ ├── guide/
├── index.md -> │ ├── index.html
└── advanced.md -> │ └── advanced.html
├── css/ (Tabler CSS)
└── js/ (Tabler JS)
- Scans the input directory recursively for
.mdfiles - Detects and copies any
favicon.*file from the input root - Converts each Markdown file to HTML using Goldmark
- Extracts headings to build sidebar navigation and breadcrumbs
- Wraps the HTML content in a Tabler UI page template
- Copies minified Tabler CSS/JS assets to the output directory
- Auto-generates an index page if no
index.mdexists at the root
- Pages use the first
h1heading as the title - If no
h1exists, falls back to the filename - When
-titleis set, sub-pages display as"Page Title - Site Name"
Place a favicon.svg, favicon.ico, or favicon.png file in the root of your documentation input directory. md2html automatically detects it, copies it to the output, and links it in every page.
Every generated page includes:
- Meta description — Auto-extracted from the first paragraph of your content (~160 chars)
- Open Graph tags —
og:title,og:description,og:typefor social media previews - Semantic HTML — Proper heading hierarchy,
<nav>elements, breadcrumb structured data - Language attribute —
<html lang="...">configured via-langflag
No extra configuration required — descriptions are derived from your actual content.
Use the -lang flag to set the HTML lang attribute:
./md2html -in ../docs -out ../dist -lang en # English
./md2html -in ../docs -out ../dist -lang ja # JapaneseDefaults to zh-CN. Accepts any BCP 47 language tag.
| Component | Library |
|---|---|
| Markdown Parser | Goldmark |
| Syntax Highlighting | Chroma (Monokai theme) |
| UI Framework | Tabler (Bootstrap-based) |
| Template Engine | Go html/template |
| Language | Go |
MIT
