PHPackages                             diogovitzo/statamic-toc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. diogovitzo/statamic-toc

ActiveStatamic-addon[Utility &amp; Helpers](/categories/utility)

diogovitzo/statamic-toc
=======================

Auto-Generated Table Of Contents from Markdown Fields for Statamic 3.

01PHP

Since Jun 18Pushed 1y agoCompare

[ Source](https://github.com/diogovitzo/statamic-toc)[ Packagist](https://packagist.org/packages/diogovitzo/statamic-toc)[ RSS](/packages/diogovitzo-statamic-toc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (1)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/528a3a6503a3a69f7dcd7fea8244adf2ad1b9ff8a6138ab687db5aa30de86dd8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a6564616d7a696b2f73746174616d69632d746f633f7374796c653d666c61742d737175617265)](https://github.com/jedamzik/statamic-toc/releases)[![Tests](https://camo.githubusercontent.com/6d376f21cff2e25c410fc873a1701470d8a25d22432603ea1a1e848c9a4021bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a6564616d7a696b2f73746174616d69632d746f632f72756e2d74657374733f6c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/6d376f21cff2e25c410fc873a1701470d8a25d22432603ea1a1e848c9a4021bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a6564616d7a696b2f73746174616d69632d746f632f72756e2d74657374733f6c6162656c3d5465737473267374796c653d666c61742d737175617265)

Toc
===

[](#toc)

> Auto-Generated Table Of Contents from Markdown Fields for Statamic 3.

This generates a Table Of Contents from a Markdown field.

A list of Headings is saved in the entry as html and can either be rendered directly using `{{ table_of_contents }}` or through the provided tag `{{ toc }}` with a customizable wrapper view.

Installation
------------

[](#installation)

Require it using Composer.

```
composer require jedamzik/statamic-toc

```

### Set up a Collection

[](#set-up-a-collection)

Publish the wrapper view and package configuration from `Njed\Toc\ServiceProvider`:

```
php artisan vendor:publish
```

Provide a collection handle and a field handle in `config/toc.php` to activate `Toc` for a given collection:

```
return [
    'collections' => [
        'posts' => 'content'
    ],
    ...
];
```

Heading Depth
-------------

[](#heading-depth)

By default only `h1` and `h2` are used for the Table of Contents. If you want to include further heading levels, add them to the config:

```
return [
    ...
    'includeLevels' => [3, 4]
];
```

List items for all headings with a level `> 2` will have a `.child` class added so you can style them separately.

Anchor Links for Headings
-------------------------

[](#anchor-links-for-headings)

Items in the Table of Contents can function as anchor links to the heading fragment:

```
return [
    ...
    'anchorLinks' => true
];
```

Linked page fragments are a slugified version of the Heading string (`Example Title` -&gt; `#example-title`).

You can extend your Markdown Parser with the provided `Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension` to provide these ids for your heading nodes in your rendered views.

To extend the default Parser for all Markdown fields in your Statamic instance, add it to your `boot` method in the `AppServiceProvider`:

```
Markdown::addExtension(function () {
    return new \Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension;
});
```

To only use this Extension on a specific Markdown field, you can create a new Parser and specify it for your Markdown field.

```
Markdown::extend('special', function ($parser) {
    return $parser
        ->withStatamicDefaults()
        ->addExtension(function () {
            return new \Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension;
        });
});
```

You can set a custom parser for markdown fields either in the control panel or through the `parser` attribute in your blueprint file:

```
-
    handle: content
    field:
        ...
        type: markdown
        parser: special
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 69% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a09cc02ab6f656627984b2e2fa97c7c23560b0c60c155a4cba36703ac2444601?d=identicon)[diogovitzo](/maintainers/diogovitzo)

---

Top Contributors

[![jedamzik](https://avatars.githubusercontent.com/u/6991523?v=4)](https://github.com/jedamzik "jedamzik (20 commits)")[![benfreke](https://avatars.githubusercontent.com/u/2102440?v=4)](https://github.com/benfreke "benfreke (3 commits)")[![diogovitzo](https://avatars.githubusercontent.com/u/45798924?v=4)](https://github.com/diogovitzo "diogovitzo (3 commits)")[![phpsa](https://avatars.githubusercontent.com/u/952595?v=4)](https://github.com/phpsa "phpsa (3 commits)")

### Embed Badge

![Health badge](/badges/diogovitzo-statamic-toc/health.svg)

```
[![Health](https://phpackages.com/badges/diogovitzo-statamic-toc/health.svg)](https://phpackages.com/packages/diogovitzo-statamic-toc)
```

###  Alternatives

[bagisto/pwa

Progressive Web Application transforms your website to a mobile application

1134.4k](/packages/bagisto-pwa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
