我能更改主标志的URL吗?

例如,假设我希望 logo 指向 forum.example.com/latest 而不是 forum.example.com,我该怎么做?这是否是我可以轻松更改而无需开发人员介入的设置?我的论坛由 Discourse 托管,这是否有影响?

我之所以希望这样设置,是因为我希望用户访问论坛时的默认页面是“分类”页面,这样论坛看起来不那么令人望而生畏。但我希望他们点击 logo 后能进入“最新”页面。

在主题中,以下代码应可生效:

<script type="text/discourse-plugin" version="0.4">
    api.changeWidgetSetting('home-logo', 'href', '/latest')
</script>

谢谢!因为我是新手,能否具体说明应该粘贴在哪里?我猜不是粘贴在 CSS 的位置吧?

它位于 HEAD 部分,在 CSS 链接的右侧。你可以在 Developing Discourse Themes & Theme Components 了解更多信息。

抱歉打扰,但如何让它在新标签页中打开而不是在当前标签页中打开?target="_blank" 在这里可用吗?

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

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

<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>

感谢您出色的解释。我通过在标题中添加一个图标链接,并将其 URL 设置为我想要的徽标指向的位置,并在另一个选项卡中打开,找到了一个解决方法。它奏效了,最终为用户提供了他们想要的(在标题中链接到外部主站点)。个人而言,我更喜欢它目前的样子,因为我喜欢使用徽标作为我的论坛主页链接。