DiscoTOC - automatic table of contents

:discourse2: Summary DiscoTOC will allow you to generate an interactive table of contents for your topics with one click!
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/DiscoTOC
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Samples

Desktop

Mobile

Features

toc = table of contents

  • Automatically generates the entire toc via a button in the composer gear menu

  • The toc will always be on the screen - scrolls with content like the topic progress widget

  • As you scroll past sections in the topic, the active element in the table of contents will be set to active (blue highlight)

  • Each toc entry links to the heading’s anchor, so you can also link to a specific section from another topic or post

  • Clicking on any link in the toc will instruct the browser to navigate to the relevant section (smooth-scrolling)

  • In topics with replies, a Contents / Timeline button lets readers switch between the toc and the normal topic timeline. The choice is remembered in the browser

  • Works with the Discourse Docs plugin

  • Optional support for tocs in replies, not just the first post

  • RTL support

How does it work?

In a nutshell, it looks for headings in topics which are marked to have a toc (via the composer button) and if it turns out the current topic is marked, then it takes all the headings and puts them in the toc (nested in order of heading levels) - this means that your markdown must be syntactically correct.

# heading 1
## heading 2
### heading 3
#### heading 4
##### heading 5

You’re free to go back and fourth in heading levels, but the order must be correct

# heading 2
## heading 3
## heading 3
### heading 4
## heading 3
# heading 2

etc...

A few things to know about which headings are compatible

  • h1 through h5 are included. h6 is not
  • Headings inside quotes are ignored, so quotes won’t pollute the toc
  • The toc only appears if the post has at least as many headings as the TOC min heading setting (3 by default)

How do the links in the toc work?

Every heading in a cooked post gets an anchor in the form p-<post id>-<heading slug>-<number> — it’s the target behind the a heading. DiscoTOC links to those anchors rather than inventing its own.

Because those anchors include the heading’s position in the post, they change if you reorder or retitle headings. If you’re linking to sections from elsewhere, you can add stable named anchors above the heading:

<div><a name="my-section"></a></div>
## My section

Then link to /t/your-topic-slug/1234#my-section. Discourse allows <a name="..."> in posts. DiscoTOC’s own entries will still use the core heading anchors, but yours will continue working regardless of edits.

Settings

Name Description
minimum trust level to create TOC The must have in order to see the TOC button in the composer
composer toc text Text that appears at of the composer to indicate the topic will have a table of contents
auto TOC categories Automatically enable categories
auto TOC tags Automatically enable TOC on topics with these tags
enable TOC for replies Allows TOC for replies. TOCs for replies are not affected by the auto TOC tags and auto TOC categories settings and must be inserted manually
TOC min heading Minimum number of headings in a topic for the table of contents to be shown

composer toc text is what shows up in the composer preview to indicate that a toc will be generated:

Translations

Translation Default
table_of_contents table of contents
insert_table_of_contents Insert table of contents
jump_bottom Jump to end
toggle_toc.show_timeline Timeline
toggle_toc.show_toc Contents
table_of_contents: "table of contents"

this is used for the button that opens the toc on mobile

insert_table_of_contents: "Insert table of contents"

this is used as the text for the toc button in the composer gear menu

toggle_toc.show_toc: "Contents"
toggle_toc.show_timeline: "Timeline"

these label the button that switches between the table of contents and the topic timeline

How do I create a toc?

  1. Write a topic with syntactically correct headings
  2. Click the toc button in the composer gear menu. By default it only appears on the first post of a topic; enable the enable TOC for replies setting to use it in replies as well
  3. Profit.

What happens to the topic progress widget when a topic has a toc?

There’s no space to show both at the same time, so in a topic with a toc the topic progress widget is hidden while you’re on the first post, and you see the toc instead. Once you scroll past the first post, the toc is replaced by the regular topic progress widget while you read replies. (With enable TOC for replies on, a reply that has its own toc shows that one instead.)

In topics with more than one post, a Contents / Timeline button lets readers switch between the two, and the preference is remembered in their browser.

On narrow screens the toc opens as an overlay via a button in the topic progress area.

Are there any downsides to using this component?

Almost everything happens client-side, so you can remove the component at any time and your posts will render as they did before. The one thing that touches your content is the composer button: it wraps the post in a <div data-theme-toc="true"> marker, which is how the component knows the post should have a toc. If you uninstall the component, that wrapper stays in the post but has no visible effect.

Limitations

h6 headings and headings inside quotes are not included in the toc.

Credit

This started as a hard fork of Greg Franko’s tocify.js library, and has since been rewritten as native Ember components. There are no external dependencies or requests.

Big thanks to @erlend_sh for lots of valuable feedback and to @david for his help with translations.

:discourse2: Hosted by us? Theme components are available to use on our Pro, Business and Enterprise plans.

Last edited by @awesomerobot 2026-07-27T16:04:08Z

Check documentPerform check on document:
182개의 좋아요
Automatic Table of Contents generation
Creative Uses of Discourse
Wiki improvement – Split content into multiple sections?
:cn: DiscoTOC 自动内容表格
Big Header - Little Header
Is anyone working on a Discourse Wiki?
How can i show a floating sticky 300x250 Adsense Ad on right side bar of topic page above the fold?
Reader Mode
What are the different ways to customize content inside a post (custom attributes and such)
How to get topic navigation menu
Traditional multi level hierarchy vs flat discourse hierarchy
How do you create a table of content like this one?
Timeline with labelled step by step sections - how is this achieved?
How To Add Marker To Table Of Contents Feature?
Theme Components - Can Discourse hosted sites install them?
Tagged topic progress bar - feasible or not?
How do I add a table of contents sidebar to a topic?
Cannot deep link to anchor in text
How can I compare arbitrary revisions of a post?
Understanding Discourse for new users
Problem with DiscoTOC: TypeError: _offsetCalculator.headerOffset is not a function
How to create an In-app Knowledge Base with Discourse Docs?
OP Contents on Progress Bar
How to get topic sidebar
Customizing your site with existing theme components
Link to headers (anchor links)
Outline Enable
What is essential content for a new community?
Tools for creating image-heavy articles
Layouts Plugin
Adding DiscoTOC to Published Pages
Customize Your Site Branding
Discourse Doc Categories
Gif icon not displaying and showing error
Must have plugins and components for Discourse?
I created a bookmarklet to create the table of content for forum posts
Could a List of Recommended Topics Be Added to the Top Menu?
?page=n URLs have high CLS hence bad SEO
Something recently changed, can't increase `--topic-body-width`
How to enable side navigation?
Displaying "full topic" text on category page + access to subcategory from menu bar
Improve iPad screen real estate
Missing anchor links in certain TOC topics?
DiscoTOC not showing in composer after latest component update
Missing anchor links in certain TOC topics?
How to create a documentation theme used by discourse
Where's Jump to end?
Handling anchors in posts created with markdown
Reader Mode
Hidden Timeline button
Horizon Theme
Collections
Bulk Export of Raw Post Sources with Markup
AI summary in topic header
Contents button and Timeline button floating unexpectedly
:cn: Discourse Post Formatting Guide 加点格式,让帖子多姿多彩
Wiki table of contents on pro plan
Living with corrupted SVGs for almost a year. Need Help!
Missing strings (DiscoTOC)
Copy pasting nested lists from Word into a post
Fix issue of TOC plug disappear
Auto-Linkify Words
Require users to "Reply as Linked Topic"
Links not working
Using Posts as a Wiki?
Using Posts as a Wiki?
Is anyone working on a Discourse Wiki?
Using Posts as a Wiki?
Using Posts as a Wiki?
DiscoTOC & Brand Header - using together
Docs: Add link to top menu
More than two levels of [details]
Category page with fixed organization of topics
Blog Post Styling
Inlink the topics within the same article
Navigating to local URL fragment doesn't modify browser history
Relating to Profile Picture Scroll Functionality
Need to include PGN (chess game notation) in a post
How can I get a table of contents for my docs?
Linking to a heading within a post
Topic list on the right side
Set up Slack notifications using the discourse-chat-integration plugin
Wrong title in the history popup (firefox)
Possible to insert post in a topic
I created a bookmarklet to create the table of content for forum posts
How to add table of content sidebar beside a topic?

4개의 게시글이 새 주제로 분리되었습니다: 게시글의 TOC를 왼쪽으로 이동하는 방법?

이 컴포넌트가 어떻게 구현되어 있는지, 또는 Discourse의 프론트엔드 구조에 대해 잘 모르기 때문에 추측만 해볼 수 있을 뿐입니다.

진행률 바를 a) 토픽에 게시물이 1개 이상일 때만 표시하고, b) 시작점을 2번째 게시물(3번째가 아닌)부터로 조정하며, c) 두 요소 중 하나에 충분한 상단/하단 여백(예: 1vh)을 추가하여 다른 요소와 충분히 거리가 있도록 해서 어색해 보이지 않게 하면 안 될까요?

다시 말해, 2번째 게시물을 전체적으로 간격으로 사용하는 대신, (게시물이 1개 이상인 경우) CSS를 활용해 그 사이에 여백을 허용하는 방식입니다.

다시 한번 말씀드리지만, 현재 이것이 어떻게 작동하는지에 대해 잘 모르기 때문에 이 제안이 전혀 무의미할 수도 있습니다.

3개의 좋아요

안녕하세요! 최근 포럼에 DiscoTOC를 설치했는데, 이 컴포넌트가 이미지 내의 alt 텍스트를 읽을 수 있는지 궁금합니다. 일부 패치 노트 헤더에 이미지를 사용하고 있는데…

이런 식으로요:
Performance and Stability

불행히도 TOC 시스템은 이미지를 헤더로 인식하지 못하는 것 같습니다. 그 결과 목록에 빈 항목이 생성되고, 빈 페이지로 연결되는 링크가 만들어집니다. “이미지를 사용하지 마세요” 외에 다른 해결책이 있을까요? 감사합니다. 그 외에는 이 시스템을 정말 좋아합니다.

1개의 좋아요

제 추측으로는 헤딩에 이미지를 사용하지 않는 것이 해결책일 수 있지만, 사이트에 일부 코드를 추가하여 DiscoTOC 코드에 연결(hook)하는 방식으로 작동하게 만들 수도 있을 것입니다. 이를 살펴볼 가치가 있는지 여부는 게시물의 헤딩에 이미지를 사용하는 것이 얼마나 중요한지에 따라 달라질 것입니다.

3개의 좋아요

오래전부터 패치 노트의 헤더로 이미지를 일관되게 사용해 왔으며, 이는 포럼뿐 아니라 스팀 등 다른 플랫폼에서도 우리의 브랜딩과 표현 방식의 일부입니다. 디스코TOC를 사용하면서도 헤더로 이미지를 계속 사용할 수 있도록 해 주시면 일관성을 유지할 수 있을 것입니다.

디스코TOC는 AMA 요약, 전용 서버 런처 앱 관련 메가포스트, 신규 플레이어 가이드 등 다른 용도에서는 매우 잘 작동하고 있습니다. 이 시스템을 매우 좋아하지만, 패치 노트를 표현하는 방식에 대해 조금 더 기능이 추가되면 좋겠습니다.

1개의 좋아요

이 컴포넌트의 헤딩 앵커 기능은 2.7.0beta6에서 추가된 자동 헤더 링크 기능과 약간 충돌합니다. 마우스를 올리면 헤딩에 아이콘이 두 개가 표시되는데, 하나는 Discourse에서, 다른 하나는 DiscoTOC에서 생성되기 때문입니다. 이 문제를 해결할 방법이 있을까요?

1개의 좋아요

안녕하세요,

자동 헤더 링크 앵커를 숨기려면 다음을 사용할 수 있습니다.

.anchor {
  display: none;
}

dodesz님, 안녕하세요.

게시물 폭을 기본값보다 훨씬 넓게 설정했는데, 이 컴포넌트를 설치한 후 뭔가 문제가 생겼습니다. 이 문제를 어떻게 해결할 수 있는지 알려주실 수 있을까요?

:heart: 감사합니다!

1개의 좋아요

Discourse 2.8.0.beta4 (90232af778)가 실행 중인 포럼에서 DiscoTOC 구성 요소를 포함하면 오류 메시지가 표시됩니다:

해당 구성 요소는 이전에 활성화된 적이 있으며, 이전에 설치된 Discourse 버전에서도 문제가 발생했습니다. 다만, 그 당시 어떤 버전이었는지는 정확히 말씀드릴 수 없습니다.

사이트의 오류 로그에서 해당 문제와 관련된 오류 메시지를 찾을 수 있나요?

그 에러 메시지는 백엔드 오류이고, DiscoTOC는 프론트엔드 테마 컴포넌트라서 둘이 관련이 있을 가능성이 낮습니다. 설치된 플러그인이 있나요?

1개의 좋아요

불행히도 /logs에서 유용한 정보를 찾지 못했습니다.

네, 있습니다. app.yml의 관련 부분을 여기에 첨부합니다:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-openid-connect.git
          - git clone https://github.com/discourse/discourse-checklist.git
          - git clone https://github.com/discourse/discourse-push-notifications.git
          - git clone https://github.com/discourse/discourse-characters-required.git
          - git clone https://github.com/angusmcleod/discourse-news.git
          - git clone https://github.com/discourse/discourse-data-explorer.git
          - git clone https://github.com/DNOeV/discourse-watch-category.git
          - git clone https://github.com/discourse/discourse-footnote.git
          - git clone https://github.com/discourse/discourse-knowledge-explorer.git
1개의 좋아요

인용문 안에 헤더가 있으면 목차에 표시되지 않습니다. 이 동작을 변경할 수 있을까요?

이 헤더는 목차에 표시되지 않습니다

인용된 내용

이 헤더는 목차에 표시됩니다

인용된 내용

정확히 어떻게 작동할지는 모르겠지만, 보통은 아닙니다. 그것은 인용문의 일부이지, 해당 텍스트의 제목이 아니기 때문입니다.

2개의 좋아요

html의 <blockquote>를 사용해 볼 수 있을까요? 그러면 헤더 #가 줄의 시작 부분에 올 수 있습니다.

예:

<blockquote>

### Anchor Header

</blockquote>

Anchor Header

목차에서는 시도해 보지 않았지만, 일반 게시물에서는 자동 앵커 헤더(auto-anchor-headers)와 함께 작동하는 것 같습니다.

인용 부호 안에 있는 헤더가 목차에 표시되기를 원하시는 이유는 무엇인가요? 사용 사례가 어떻게 되시나요?

좋은 아이디어를 주셔서 감사합니다. 하지만 제 경우에는 작동하지 않았습니다.

다음은 ‘Issue Area: Age’ 아래에서 시작되는 콘텐츠를 시각적으로 구조화하기 위해 인용구를 사용하는 예시입니다.

3개의 좋아요

왜 그렇게 인용을 사용하나요? 출처를 명시하는 것만으로도 충분합니다. 게다가 문법적으로도 틀렸으며, 영어에서도 마찬가지입니다.

이게 버그인지 아니면 그냥 다른 사용자 문제인지 모르겠는데… TOC를 어떻게 닫아야 하나요? 일반 사용자가 개인 메시지를 사용하는 방법에 대한 기본적인 설명을 찾고 있었는데, 당연히 신규 사용자 문서로 가서 관련 정보가 있는지 확인하려고 TOC를 열었습니다.

iPad와 DiscourseHub를 사용 중이었습니다.

이런 화면이 떴습니다:

TOC 자체는 정상입니다. 하지만 텍스트 위에 겹쳐 있고, 다시 접을 수가 없었습니다. 그래서 대체 제가 뭘 잘못했는지, 아니면 아예 잘못한 게 없는 건지 모르겠습니다 :pleading_face: