Add a title to your Tocbot TOC

I used this tutorial to add a TOC to my posts. However, that method doesn’t include a title for the TOC, so it becomes unlabeled headings in the margin, like so:

The following CSS will add a title similar to what Ghost itself uses. (Edit “Table of Contents” to whatever title you prefer.)

    .gh-toc::before {
      content: "Table of Contents";
      display: flex;
      font-weight: bold;
    }

To add some space between the title and the headings, add padding to toc-list:

    .toc-list {
        overflow: hidden;
        padding-top: 10px;
        list-style: none;
    }

The result:

3 Likes