# DiscoTOC - 自动生成目录

**URL:** <https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143>\
**Category:** Theme component\
**Tags:** official, disco-toc\
**Created:** [2019年三月9日 05:36 UTC](https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143 "2019-03-09T05:36:22Z")\
**Posts on this page:** 1\
**Showing post:** 488

<div class="post-metadata">

**Author:** ![one1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/one1/32/493591_2.png) [@one1](https://meta.discourse.org/u/one1)\
**Post date:** [2026年七月27日 08:16 UTC](https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143/488 "2026-07-27T08:16:08Z")

</div>

> [@Discourse](#):
>
> 为了让目录中的链接正常工作，标题必须具有 id 属性。该组件会检查标题是否已有 id，如果已有，则会保留这些 id。如果你曾手动创建过目录，这会非常方便。

能否有人解释一下如何给标题添加 id 属性？我尝试了这里的方法：[Extended Syntax | Markdown Guide](https://www.markdownguide.org/extended-syntax/#heading-ids) 在标题行末尾添加 `{#custom-id}`。我也直接使用了 HTML `h1` 标签并添加了 id。但这些都行不通。

文档是否已不再准确？如果可以添加我自己的 id，那就能解决我在 [这里](https://meta.discourse.org/t/hash-anchors-are-being-stripped-from-urls-on-mobile-how-to-stop-that/408505) 遇到的问题，前提是这些 id 在各种锚点标签的情况下都能正常工作。

---

_[View the full topic](https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143)._
