# 全局更改图标

**URL:** <https://meta.discourse.org/t/change-icons-globally/87751>\
**Category:** Developer Guides\
**Tags:** how-to\
**Created:** [2018年五月17日 15:45 UTC](https://meta.discourse.org/t/change-icons-globally/87751 "2018-05-17T15:45:00Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![porterbayne](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@porterbayne](https://meta.discourse.org/u/porterbayne)\
**Post date:** [2019年九月15日 14:44 UTC](https://meta.discourse.org/t/change-icons-globally/87751/17 "2019-09-15T14:44:12Z")

</div>

谢谢！我还找到了这篇帖子：[在主题中用自定义图标替换 Discourse 的默认 SVG 图标](https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736)

最终，我直接将 SVG 精灵嵌入到 Header 文件中，因为按照那篇文章所述上传并重命名对我无效（当然，也可能是我操作有误）。

所以我的 Header 是这样的：

```
<svg width="0" height="0" class="hidden" style="display: none;">
    <symbol id="myicon-search" ..... </symbol>  
    <!-- 我所有的符号都在这里... -->
</svg>
<script type="text/discourse-plugin" version="0.8">
    api.replaceIcon('search', 'myicon-search'); 
</script>

```

这样管理起来很方便。

我使用 [https://svgsprit.es](https://svgsprit.es/) 上的 SVG 精灵生成器来确保格式正确。

---

_[View the full topic](https://meta.discourse.org/t/change-icons-globally/87751)._
