Koki's personal blog

Koki's personal blog

Another fine, responsive site template by HTML5 UP.

Making a table of contents of Markdown automatically

Explain how to make a table of contents of Markdown automatically.

Koki

2-Minute Read

This article explains how to make a table of contents of Markdown automatically..

The following lists are the table of contents about this article.

Target audience

  • Those who want to make a table of contents of Markdown automatically.

Preconditions

  • Installed Node.js

Install doctoc

Execute the following command.

npm install -g doctoc

Making a table of contents of Markdown automatically

Specify the directory where contains the Markdown file for making the table of contents exists in the doctoc parameter, and execute it. For the following example, specifying current directory.

doctoc .

Wait to show “Everything is OK.”. Then open the file, the table of contents has been added to the top between the following comments.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/t
<!-- END doctoc generated TOC please keep comment here to allow auto update -->

After that, use it freely.

By the way, the table of contents of this article was output in the following form.

- [Target audience](#target-audience)
- [Preconditions](#preconditions)
- [Install doctoc](#install-doctoc)
- [Making a table of contents of Markdown automatically](#making-a-table-of-contents-of-markdown-automatically)
- [Reference articles](#reference-articles)

Reference articles

Recent Posts

Categories