Roadmarks

Tables of contents that keep up with your docs

Roadmarks writes the navigation in your Markdown files. Mark a place with an HTML comment, run one command, and get links to every heading in the file and every page in your docs folder. Run it again after you change something, and the links follow.

npm install --save-dev roadmarks
npx roadmarks

Read the docs

Before and after

Put an empty comment pair where the links go. tree:docs asks for the pages in the docs folder as well as the headings.

Before: README.md
# My project

<!-- RM(tree:docs) -->
<!-- /RM -->

## Install

## Usage
After: npx roadmarks
# My project

<!-- RM(tree:docs) -->

* [Install](#install)
* [Usage](#usage)
****

* [docs](./docs)
  * [Configuration](./docs/configuration.md)
  * [Deployment](./docs/deployment.md)

<!-- /RM -->

## Install

## Usage

GitHub, npm, and other Markdown viewers hide the comments and show the links. Everything between the comments belongs to Roadmarks; everything outside them stays yours.

Headings

A nested list of the headings in the file, with links to their anchors. Set depth to list fewer levels.

Trees of files

Every Markdown page in a folder tree, listed by title. A README.md stands for its folder.

Navigation

Links to the parent, the top, and the previous and next page, so readers can move through the docs on GitHub.

Indexes

Lists or tables of the images and definitions in your docs, with links to the pages that use them.

Usage

Run it in the project folder to process every Markdown file, or point it at a folder or a single file:

roadmarks
roadmarks -d path/to/project
roadmarks -f docs/guide.md

Options go in brackets in the comment. Wrap any part of a file in an ignore block to keep it out:

<!-- RM(tree:*,depth:2,nocontent) -->
<!-- /RM -->

<!-- RM-IGNORE -->
## Not in the table of contents
<!-- /RM-IGNORE -->

Roadmarks skips node_modules, files that .gitignore lists, and folders with their own Git repository. See Command line and Markup for every option.

Docs

Free, and kept up to date

Roadmarks is free and MIT licensed. If it saves you time, a coffee helps me keep it working with each new Node.js release.

Support me on Ko-fi