# カスタムサイドバーリンクを新しいタブで開くように設定する

**URL:** https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004
**Category:** Feature
**Tags:** sidebar
**Created:** [2023 年 6 月 1 日午前 11:09 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004 "2023-06-01T11:09:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![kinetiksoft](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kinetiksoft/32/229578_2.png) [@kinetiksoft](https://meta.discourse.org/u/kinetiksoft)
#### Post date: [2023 年 6 月 1 日午前 11:09 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/1 "2023-06-01T11:09:37Z")

</div>

カスタムセクションリンクを新しいタブで開くために `_blank` にすることは可能ですか？多くのテーマコンポーネントもこの機能を提供しています。

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [2023 年 6 月 2 日午前 10:08 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/2 "2023-06-02T10:08:00Z")

</div>

サイドバーの外部リンクを新しいタブで開くかどうかについては、以前議論したことがありますが、ユーザーの好みを尊重することにしました。

ご自身のサイトで、ユーザーの好みを上書きしてリンクを新しいタブで強制的に開いた方が良いと思われる事例を1つか2つ教えていただけますか？

---

<div class="post-metadata">

### Author: ![kinetiksoft](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kinetiksoft/32/229578_2.png) [@kinetiksoft](https://meta.discourse.org/u/kinetiksoft)
#### Post date: [2023 年 6 月 2 日午前 10:22 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/3 "2023-06-02T10:22:05Z")

</div>

確かに。アプローチが違うだけかもしれません。リンクが外部リンクである場合、ユーザーのブラウザを別のタブに転送する方がはるかに丁寧だと心から信じています。これにより、フォーラムのページで体験していることや体験していたことを中断させることがなくなります。

私たちのフォーラムは非常に活発であり、ユーザーがリンクをたどってウェブサイトを完全に離れることで中断されることが問題ないかどうかはわかりません。この場合、リンクは私たちのTelegramチャンネルにつながります。

結局のところ、外部リンクをデフォルトで \_blank で開くことを提案しているわけではありません。Discourse管理者に、この特定のコンポーネント/構成機能からリンクがどのように開くかを制御する機能を与えることを提案しています。

---

<div class="post-metadata">

### Author: ![twofoursixeight](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/twofoursixeight/32/574822_2.png) [@twofoursixeight](https://meta.discourse.org/u/twofoursixeight)
#### Post date: [2023 年 6 月 3 日午後 12:22 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/4 "2023-06-03T12:22:34Z")

</div>

一時的な解決策: アイテムを右クリックすると、新しいタブで開くオプションが表示されます。

> [@kinetiksoft](#):
>
> 確かに。おそらく私たちのやり方は違うのでしょう。リンクが外部リンクである場合、ユーザーのブラウザを別のタブに転送する方がはるかに丁寧だと心から信じています。これにより、フォーラムのページで体験している、または体験していたことを中断することなく済みます。

リンクが新しいタブで開かれる場合、進捗が中断されることは決してありません。同意します。

---

<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: [2023 年 6 月 3 日午後 12:31 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/5 "2023-06-03T12:31:26Z")

</div>

> [@kinetiksoft](#):
>
> この特定のコンポーネント/構成機能からリンクが開かれる方法を Discourse 管理者が制御できるようにすることをお勧めします。

これには同意します。上記の Telegram チャネルのシナリオのように、管理者が作成したカスタムリンクでユーザー設定をオーバーライドすることが理想的な場合があります。テーマコンポーネントでは \_blank を頻繁にターゲットにしているので、このオプションがカスタムサイドバー構成モーダルの一部としてなぜ存在しないのか分かりません（スペースがなく、そこに収まらないという場合を除いて）。

実際、私のフォーラムにも管理者がカスタマイズしたサイドバーリンクがあり、リンクのユーザー設定をオーバーライドしたいと考えています。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023 年 6 月 3 日午後 1:09 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/6 "2023-06-03T13:09:29Z")

</div>

> [@kinetiksoft](#):
>
> リンクが外部リンクである場合、ユーザーのブラウザを別のタブに転送する方が丁寧だと心から信じています。

> [@kinetiksoft](#):
>
> リンクが外部リンクである場合、ユーザーのブラウザを別のタブに転送する方が丁寧だと心から信じています。

ユーザーが同じウィンドウでリンクを開くことを好むと表明した場合、彼らが明確に示したこととは異なることを行う方が丁寧だとお考えですか？

スクリーンリーダーを使用しているユーザーは、予期せず新しいタブで開かれた場合に最も不便を感じます。そのため、通常はリンクを新しいタブにハイジャックしないことが推奨されています（あなたや私が好むことですが）。

ユーザーのデフォルト設定を新しいタブで開くように変更し、その設定をすべてのユーザーに適用できます。これにより、ユーザーの設定を侵害することなく、サイトをより丁寧にすることができます。

---

<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: [2023 年 6 月 3 日午後 1:53 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/7 "2023-06-03T13:53:34Z")

</div>

> [@pfaffman](#):
>
> スクリーンリーダーを使用しているユーザーは、予期せず新しいタブで開かれた場合に最も不便を感じます。そのため、リンクを新しいタブにハイジャックすることは一般的に推奨されていません（それがあなたと私が好むことであるにもかかわらず）。

これは非常に良い点です。

---

<div class="post-metadata">

### Author: ![ClawdiaWolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clawdiawolf/32/262518_2.png) [@ClawdiaWolf](https://meta.discourse.org/u/ClawdiaWolf)
#### Post date: [2023 年 6 月 4 日午前 12:00 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/8 "2023-06-04T00:00:51Z")

</div>

> [@pfaffman](#):
>
> スクリーンリーダーを使用しているユーザーは、予期せず新しいタブで開かれた場合に最も不便を感じます。そのため、リンクを新しいタブに強制的に開くことは一般的に推奨されていません（それがあなたや私のお気に入りであっても）。

実際にスクリーンリーダーを使用している者（そして、テーマコンポーネントがそれらに対して引き起こす多くの問題も経験しています）として、新しいタブを強制することは一般的に悪い考えであることを確認できます。

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [2023 年 12 月 4 日午後 6:17 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/9 "2023-12-04T18:17:59Z")

</div>

サイドバーから姉妹ウェブサイトへのカスタムリンクを新しいタブで開くのを無効にするにはどうすればよいですか？他のウェブサイトにもDiscourseに戻るリンクがあります。現在、これにより多くの不要なタブが開かれます。

その外部リンクは\_selfで開くようにしたいです。

よろしくお願いします。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2023 年 12 月 4 日午後 6:45 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/10 "2023-12-04T18:45:56Z")

</div>

通常、すべてのリンクは \_self に開く必要があります。ユーザーは、いつ、どのリンクを新しいタブまたはウィンドウで開くべきか尋ねています。

---

<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: [2023 年 12 月 4 日午後 7:45 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/11 "2023-12-04T19:45:41Z")

</div>

管理 - 設定で、以下が無効になっていることを確認してください。

 ![IMG_1199](https://global.discourse-cdn.com/meta/original/4X/d/1/d/d1d6eda88a7ff9b4650c36617bec31aee4812bc1.jpeg)

ログインユーザーは、インターフェースタブの下にあるユーザー設定で管理設定を上書きできることに注意してください。

 ![IMG_1200](https://global.discourse-cdn.com/meta/original/4X/3/7/c/37c3f4749d3200d4b63509c6cb1a5c84a14d5e72.jpeg)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2023 年 12 月 4 日午後 8:14 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/12 "2023-12-04T20:14:51Z")

</div>

リンク先サイトへのリンクを1つだけ設定する方法についての質問だったと思います。そのサイトにはフォーラムへのリンクも含まれています。管理者の設定を変更すると、すべてのリンクの動作が変わってしまうのではないでしょうか？

---

<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: [2023 年 12 月 4 日午後 8:57 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/13 "2023-12-04T20:57:50Z")

</div>

うーん、ありえる。ユーザー設定を上書きしたいのでしょうか？リンクを別タブ/ウィンドウで開くことに影響する設定は、それしか知りません。

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [2023 年 12 月 5 日午後 8:29 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/14 "2023-12-05T20:29:53Z")

</div>

はい、外部サイトのターゲット \_blank をグローバルに無効にしたくありません。この単一のメニュー項目に対してのみ無効にしたいのです。

説明ありがとうございます。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023 年 12 月 6 日午後 4:37 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/15 "2023-12-06T16:37:57Z")

</div>

[Custom Header Links](https://meta.discourse.org/t/custom-header-links/90588) は、追加するリンクのターゲットを選択できます。これが役立つかもしれません。

[https://github.com/discourse/discourse-custom-header-links/blob/main/javascripts/discourse/components/custom-header-links.hbs#L18](https://github.com/discourse/discourse-custom-header-links/blob/main/javascripts/discourse/components/custom-header-links.hbs#L18)

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [2023 年 12 月 6 日午後 4:49 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/16 "2023-12-06T16:49:55Z")

</div>

はい。サイドバーにはこれを使用しますか？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023 年 12 月 6 日午後 4:55 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/17 "2023-12-06T16:55:40Z")

</div>

ヒントです。これが最善です。正直なところ、サイドバーの変更についてはよくわかりません。

サイドバーにはまだプラグインのアウトレットがないようです（！？）、そのため、変更したいものを見つけるには、巧妙なJavaScriptが必要になるかもしれません。おそらく[これ](https://thesassway.com/how-to-change-href-tag-with-css/)のようなものです。

---

<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 年 12 月 6 日午後 5:34 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/18 "2023-12-06T17:34:19Z")

</div>

> [@pfaffman](#):
>
> サイドバーにプラグインのアウトレットがまだないようです

これは意図的なものです。理想的には、APIを使用してサイドバーを拡張する必要があります…これにより、ここに追加されたカスタムリンク/セクションを維持できます。

現在、外部リンクのターゲットは、ユーザー設定 `external_links_in_new_tab` に基づいてすべてまたはなしになっています…そのため、API経由でカスタムセクション/リンクが追加された場合でも、特定のリンクのターゲットを変更する方法はありません。このオプションを追加することは可能ですが…歴史的には、リンクの開き方に関するユーザーの好みを尊重する傾向があります。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023 年 12 月 6 日午後 5:40 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/19 "2023-12-06T17:40:34Z")

</div>

> [@awesomerobot](#):
>
> 理想的には、API を使用してサイドバーを拡張する必要があります

なるほど、そういうことだったんですね。その件については見落としていたようです。しかし、もう少し詳しく見てみると、`plugin-api.js` の中に `addSidebarPanel` と `addSidebarSection` があるのですが、後者だけが投稿にヒットし、それは「ハウツー」とは程遠いものです。しかし、これがあります。

[https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/lib/plugin-api.js#L2306-2310](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/lib/plugin-api.js#L2306-2310)

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [2026 年 5 月 29 日午前 10:21 UTC](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004/20 "2026-05-29T10:21:36Z")

</div>

> [@awesomerobot](#):
>
> 現時点では、外部リンクのターゲットは、ユーザー設定の `external_links_in_new_tab` に基づいて「すべて」または「なし」のようです。

その通りです。親ウェブサイトへのリンクがあり、訪問者が往復することが多いため、新しいタブやウィンドウで開かないようにしたいと考えています。あるいは、むしろ「往復」ではなく「行ったり来たり」ですね。😂

[Next page](https://meta.discourse.org/t/configure-a-custom-sidebar-link-to-open-in-a-new-tab/267004.md?page=2)
