Get Ghost TOC up and running in 5 minutes.
Upgrading from Gist? This repository replaces the older Gist versions (v1.0, v2.1). Just swap the old script for the new one - everything else stays the same!
<script> tags)✅ Done! The script is now active on your entire blog.
<toc title="Table of Contents"></toc>
✅ Your TOC will appear automatically!
Instead of typing the TOC code every time:
✅ Now you can add TOC to any post by typing /TOC
💡 New to Ghost snippets? Learn more about how snippets work in Ghost’s official snippets guide.
<toc title="Contents"></toc>
<toc
title="Table of Contents"
collapsible="true"
show-text="Show"
hide-text="Hide">
</toc>
<toc
title="In This Article"
collapsible="true"
show-text="▼ Expand"
hide-text="▲ Collapse"
border-color="#e0e0e0"
bg-color="#f9f9f9">
</toc>
<toc
title="Contents"
collapsible="true"
default-state="collapsed"
remember-state="true">
</toc>
<toc
title="Quick Navigation"
levels="2,3">
</toc>
<toc
title="Steps in This Tutorial"
list-style="numbers">
</toc>
Save different snippets for each language:
<toc title="Table of Contents"></toc><toc title="Tabla de Contenidos"></toc><toc title="Inhaltsverzeichnis"></toc><toc title="Table des Matières"></toc>Ghost TOC automatically:
💡 Place TOC after your intro: Add the TOC after your opening paragraphs, before the main content
💡 Use descriptive headings: Your TOC is only as good as your heading structure
💡 Test in preview: Always preview your post to verify TOC appears correctly
💡 Heading IDs required: Ghost automatically adds IDs to headings - if links don’t work, check that headings have id attributes
<toc> not <TOC><h2 id="my-section">My Section</h2>| Time invested: 5 minutes | Benefit: Enhanced navigation for all your blog posts 🚀 |