# 在主题中用自定义图标替换 Discourse 的默认 SVG 图标

**URL:** <https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736>\
**Category:** Developer Guides\
**Tags:** how-to, theme-guides\
**Created:** [2019年四月23日 16:43 UTC](https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736 "2019-04-23T16:43:06Z")\
**Posts on this page:** 1\
**Showing post:** 39

<div class="post-metadata">

**Author:** ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)\
**Post date:** [2025年一月18日 03:59 UTC](https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736/39 "2025-01-18T03:59:57Z")

</div>

> [@Discourse](#):
>
> ```plaintext
> <script type="text/discourse-plugin" version="0.8">
> api.replaceIcon('bars', 'mytheme-icon-bars');
> api.replaceIcon('link', 'mytheme-icon-link');
> <!-- etc -->
> </script>
> 
> ```

这不起作用。我尝试了：

```html
<script type="text/discourse-plugin" version="0.8">
    api.replaceIcon("shield-halved", "hat-wizard");
</script>

```

[来自这里](https://meta.discourse.org/t/differentiate-admin-and-moderator-shield-icons/106114/40?u=natedhaliwal)，但似乎不起作用。我认为脚本标签方法已损坏，因为[这个](https://discourse.theme-creator.io/theme/Discourse/custom-topic-button)在预览链接中不起作用。老实说，我不确定。

---

_[View the full topic](https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736)._
