# 我能更改主标志的URL吗？

**URL:** <https://meta.discourse.org/t/can-i-change-the-url-of-the-main-logo/186127>\
**Category:** Development\
**Created:** [2021年四月8日 19:17 UTC](https://meta.discourse.org/t/can-i-change-the-url-of-the-main-logo/186127 "2021-04-08T19:17:14Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2023年四月3日 14:49 UTC](https://meta.discourse.org/t/can-i-change-the-url-of-the-main-logo/186127/6 "2023-04-03T14:49:00Z")

</div>

这需要更多的自定义，因为它在此处的 home-logo 小部件中被阻止：

> <https://github.com/discourse/discourse/blob/2dbcea9eeeb816dda347027497b3a49634ef851f/app/assets/javascripts/discourse/app/widgets/home-logo.js#L140>

所以您必须使用 `changeWidgetSetting` 来设置 URL，然后使用 `reopenWidget` 来添加 `_blank` 并覆盖阻止在新窗口中打开的默认单击行为。

```xml
<script type="text/discourse-plugin" version="0.8">
  const { h } = require("virtual-dom");

  api.changeWidgetSetting('home-logo', 'href', 'https://discourse.org');

  api.reopenWidget("home-logo", {
     html() {
       return h(
         "a",
         { attributes: { href: this.href(), "data-auto-route": true, "target": "_blank" } },
         this.logo()
       );
     },

     click(e) {
       return;
     },
   });
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/can-i-change-the-url-of-the-main-logo/186127)._
