Table of Contents
Generate table of contents automatically.
Something looks broken? We accept bounties to fix them faster.
^ | 270 Downloads |
---|---|
v2.5.2 | 290 Downloads |
v2.5.1 | 208 Downloads |
v2.1.0 | 142 Downloads |
v1.3.0 | 349 Downloads |

This extension lets you build automatic table of contents on the page that has several headers in it so that you can use it to navigate between page headers. If you set the type
value to 2
, table of contents will not be inserted to the page content, and this extension will only serves as an automatic permanent link ID generator for all header elements in your page content.
Basic Usage
Custom Header ID
You have the full control to determine your own header ID with Markdown Extra syntax or with plain HTML markup. This extension will not overwrite the specific ID that you have specified in the header elements:
#### Header Special {#special}
<h3 id="special">Header Special</h3>
Advance Usage
Exclude Headers from TOC
Add not:t-o-c
class to the desired headers to exclude them from the TOC tree and to disable the automatic permanent link ID creation:
#### Example Header {.not:t-o-c}
<h3 class="not:t-o-c">Example Header</h3>
Custom Placement
If you have Block extension installed, you can put [[t-o-c]]
block anywhere in the page content to mark the position you want to put the generated TOC tree to:
---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: Markdown
...
First paragraph goes here.
Custom Title for Table of Contents
Second paragraph goes here.
Third paragraph goes here.
Disable TOC
There are several ways to disable the automatic table of contents placement.
First way is through the extension configuration, that is, by setting the value of the type
property to 0
or false
(alias for 0
). This will disable the table of contents by default:
<?php
return [
'type' => 0,
'id' => [ … ],
'class' => [ … ]
];
To re-enable the table of contents, set the value of t-o-c
property within your page’s state
property as 1
, 2
or true
(alias for 1
):
---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: Markdown
state:
t-o-c: true
...
Second way is through the page properties. To disable the automatic table of contents placement on certain page, add a t-o-c
property within your page’s state
property with a value that can be evaluated to false
:
---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: Markdown
state:
t-o-c: false
...
Override TOC Configuration Data
You can rewrite the TOC configuration data on the t-o-c
property to override the initial configuration data:
---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: Markdown
state:
t-o-c:
type: 2
class:
- table-of-contents
...