# 根据索引中由其 slug 标识的高亮显示当前文档主题在侧边栏中

**URL:** https://meta.discourse.org/t/highlight-current-doc-topic-in-the-sidebar-identified-by-their-slugs-in-the-index/392857
**Category:** Feature
**Tags:** doc-categories
**Created:** [2026 年1 月 6 日 17:17 UTC](https://meta.discourse.org/t/highlight-current-doc-topic-in-the-sidebar-identified-by-their-slugs-in-the-index/392857 "2026-01-06T17:17:10Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### 作者： ![Neil\_Evans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil_evans/32/511055_2.png) [@Neil\_Evans](https://meta.discourse.org/u/Neil_Evans)
#### 发布日期： [2026 年1 月 6 日 17:17 UTC](https://meta.discourse.org/t/highlight-current-doc-topic-in-the-sidebar-identified-by-their-slugs-in-the-index/392857/1 "2026-01-06T17:17:10Z")

</div>

我正尝试仅使用 slug 来定义 TOC 索引项，而不是在 URL 末尾添加主题索引——这样我就可以在不同环境（开发/生产）中保持相同的 TOC 索引。

这似乎有效（因为它仅使用 slug 导航到正确的主题），但除非我在每个 URL 末尾也添加 ID，否则左侧菜单中的当前主题不会高亮显示。有没有变通的方法？

---

_[View the full topic](https://meta.discourse.org/t/highlight-current-doc-topic-in-the-sidebar-identified-by-their-slugs-in-the-index/392857)._
