md-compose is a lightweight Node.js utility to include Markdown files
inside other Markdown files using a simple [[[path/to/file.md]]] syntax.
Perfect for building modular documentation, reusable templates, and large Markdown projects.
- 🧩 Include one Markdown file into another
- ⚡ Works recursively — assemble complex documents easily
- 🧱 Keeps your docs modular and maintainable
- 🪶 Simple, dependency-free, and lightweight
npm install md-composeUse the special [[[ path/to/file.md ]]] syntax inside a Markdown document to include another Markdown file.
# Common Header for All Pages... and the second one in footer.md.
Follow me on [Github](https://github.com/fxxr)[[[ header.md ]]]
...Page content...
[[[ footer.md ]]]// Async version
import processIncludes from 'md-compose'
const result = await processIncludes('page.md')
console.log(result)
// Sync version
import {processIncludesSync} from 'md-compose'
const resultSync = await processIncludesSync('page.md')
console.log(resultSync)Output:
# Common Header for All Pages
...Page content...
Follow me on [Github](https://github.com/fxxr)- Combine multiple Markdown files into a single document
- Reuse common sections like headers, footers, or legal disclaimers
- Simplify large documentation or static site projects
- Automate assembling Markdown files before publishing
- Only Markdown files with
.mdextension are supported - Only local relative paths are allowed
- Paths are resolved relative to the current Markdown file
- Parent directory references (
..) are disallowed for safety
Contributions, issues, and feature requests are welcome!
Open an issue or
submit a pull request.