# Tag Icons 突然将 slug 中的下划线转换为连字符，导致图标失效

**URL:** <https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428>\
**Category:** Bug\
**Tags:** tags, tag-icons\
**Created:** [2026年五月20日 07:16 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428 "2026-05-20T07:16:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AquaL1te](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aqual1te/32/201966_2.png) [@AquaL1te](https://meta.discourse.org/u/AquaL1te)\
**Post date:** [2026年五月20日 07:16 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/1 "2026-05-20T07:16:37Z")

</div>

我已经设置了以下内容，之前效果很好。但几周以来，它不再正常工作了。

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/5/e/d5e783f32a3aad9d654d90ece31add32129f3621.png)

因此，这些标签在侧边栏中应该如下所示，它们确实如此，但在话题中却不是。

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/8/e/48e7e04d342bdb47acb07635ae77a33002cb8c41.png)

正如您所看到的，它在侧边栏中工作正常，但当我查看话题和标签概览时。

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/7/7/e7759049c0980ace563368115e52b6f83fdeeafe.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/b/c/7bc7d57e4d9b35a8920889fdb98cd9ff8f56519a.png)

并非所有标签都显示 \>\> 图标。

我该如何修复或更好地排查此问题？

还有更多缺失的标签图标，它们在主题组件中已配置，且过去一直正常工作。

> **[Tags](https://tzm.one/tags)**
>
> Tags

我使用的是最新的 Discourse 版本（2026.5.0-latest.1 ([4f17eef310](https://github.com/discourse/discourse/commits/4f17eef310094fb07f70c0c9b3024d0374aa5fcf)）以及此主题组件的最新版本。

---

<div class="post-metadata">

**Author:** ![gilles](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gilles/32/549022_2.png) [@gilles](https://meta.discourse.org/u/gilles)\
**Post date:** [2026年五月20日 08:18 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/2 "2026-05-20T08:18:08Z")

</div>

在我这里可以正常工作，所以我认为可能是与其他组件或插件存在冲突。请尝试禁用各个组件，以排查具体是哪个组件导致了冲突。

---

<div class="post-metadata">

**Author:** ![AquaL1te](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aqual1te/32/201966_2.png) [@AquaL1te](https://meta.discourse.org/u/AquaL1te)\
**Post date:** [2026年五月20日 09:10 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/3 "2026-05-20T09:10:13Z")

</div>

你有论坛的网址吗？也许我可以对比一下某些情况。也许是标签数量或其他类似因素触发了这个问题。因为我 95% 的标签都能正常工作。我可以尝试禁用一些组件，但这需要更多时间。

---

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2026年五月20日 09:35 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/4 "2026-05-20T09:35:19Z")

</div>

在安装此组件并进行测试之前，我猜测问题出在标签名称中的 `_` 下划线。看起来所有包含下划线的标签都没有显示其图标。

 ![Screenshot 2026-05-20 at 2.28.49 AM](https://global.discourse-cdn.com/meta/original/4X/6/b/f/6bf4a3e2b6def2a31fc7b781f8e769ab451e4da9.png)

![Screenshot 2026-05-20 at 2.29.00 AM](https://global.discourse-cdn.com/meta/original/4X/9/d/2/9d272bd09154622275fea41cc3ae1ecbbf08efec.png)

我认为这个提交将你带有下划线 `_` 的标签 slug 重新配置为连字符 `-`。

> <https://github.com/discourse/discourse-tag-icons/commit/46ee338ae4fb7b316e25501744e779f5f96c48e9>
>
> When content localization is enabled, tag icons break because the component matc…hes on \`tag.name\` which gets translated.
> 
> This switches iconTagRenderer to match on tag.slug instead. Slugs are not translated, and matches the actual description of the setting as well.

 ![Screenshot 2026-05-20 at 2.34.59 AM](https://global.discourse-cdn.com/meta/original/4X/d/9/9/d99485581d3db92ac69a09c47a19b206fda16a43.png)

---

<div class="post-metadata">

**Author:** ![AquaL1te](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aqual1te/32/201966_2.png) [@AquaL1te](https://meta.discourse.org/u/AquaL1te)\
**Post date:** [2026年五月20日 11:16 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/5 "2026-05-20T11:16:30Z")

</div>

这个提交很奇怪，为什么一个组件需要改变这种行为？这让事情变得不可预测。当我在主题组件中将 `strategic_access` 改为 `strategic-access` 时，它在话题中有效，但在侧边栏中却出错了。

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/9/c/79c560777fec8d3758a01fef357e8a4c023dfe27.png)

---

<div class="post-metadata">

**Author:** ![AquaL1te](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aqual1te/32/201966_2.png) [@AquaL1te](https://meta.discourse.org/u/AquaL1te)\
**Post date:** [2026年八月24日 10:37 UTC](https://meta.discourse.org/t/tag-icons-suddenly-converting-underscores-to-dashes-in-slugs-breaking-the-icon/403428/6 "2026-08-24T10:37:55Z")

</div>

该问题仍然存在，请问有解决方案或临时变通方法吗？还是只能坐等修复？我并不想通过更改标签来解决。
