# 如何阻止链接显示网站

**URL:** <https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955>\
**Category:** Support\
**Created:** [2022年十二月27日 11:51 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955 "2022-12-27T11:51:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beca\_Lewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/beca_lewis/32/286210_2.png) [@Beca\_Lewis](https://meta.discourse.org/u/Beca_Lewis)\
**Post date:** [2022年十二月27日 11:51 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/1 "2022-12-27T11:51:57Z")

</div>

有没有办法在消息或帖子中放置链接而不显示页面？

当我放置指向我会员网站上某个页面的链接时，它不会显示链接，而是显示用户未登录的消息，这令人困惑。

我想发布一个链接，但不显示网站本身。如果可能的话，让该链接在新标签页中打开那就太棒了。

---

<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:** [2022年十二月27日 12:40 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/2 "2022-12-27T12:40:17Z")

</div>

我的理解对吗——你不想要这个：

> [@Use google search by default](https://meta.discourse.org/t/use-google-search-by-default/249951):
>
> Can I use google search by default for discourse searches? So can I convert it to a google search like “search term site:domanin.com”.

而是想要这个：

[https://meta.discourse.org/t/use-google-search-by-default/249951](https://meta.discourse.org/t/use-google-search-by-default/249951)

如果是这样，你可以使用这个而不是普通网址来获取它：

```plaintext
<https://meta.discourse.org/t/use-google-search-by-default/249951>

```

---

<div class="post-metadata">

**Author:** ![Beca\_Lewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/beca_lewis/32/286210_2.png) [@Beca\_Lewis](https://meta.discourse.org/u/Beca_Lewis)\
**Post date:** [2022年十二月27日 12:42 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/3 "2022-12-27T12:42:14Z")

</div>

太棒了！所以我只需要把它放在括号里？太棒了！你有没有办法让它在新标签页中打开？

---

<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:** [2022年十二月27日 12:48 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/4 "2022-12-27T12:48:27Z")

</div>

默认情况下，你无法创建内部链接，我估计。

你可以尝试使用 `<a>` 标签，如下所示：

`<a> href="https://meta.discourse.org/t/use-google-search-by-default/249951" target="_blank">链接文本在此</a>`

我不知道它是否有效，但很容易尝试 😉

Just testing

_编辑_：在这里不起作用

外部链接遵循管理员设置的“默认在新标签页打开其他外部链接”。

---

<div class="post-metadata">

**Author:** ![Beca\_Lewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/beca_lewis/32/286210_2.png) [@Beca\_Lewis](https://meta.discourse.org/u/Beca_Lewis)\
**Post date:** [2022年十二月27日 13:02 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/5 "2022-12-27T13:02:27Z")

</div>

谢谢，我想知道带有 target blank 的常规 html 链接是否会起作用……感谢您的帮助。如果不可以……也没关系！

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2022年十二月27日 16:23 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/6 "2022-12-27T16:23:30Z")

</div>

> [@Jagster](#):
>
> _编辑_：在这里不起作用

您的链接在您的消息中具有 `target="_blank"` 属性，左键单击时会在新标签页中打开，所以它起作用了，除非我有什么误解？

另外，如果我引用您的消息，它会将您的链接转换为标准 markdown 链接并修剪 `target` 属性，从而在新标签页中打开。

* * *

编辑：哦，您编辑了您的消息，所以我的消息现在有点没意义了。但仍然，一个 `target="blank"` 的 [手动链接](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955) 可以工作，值得注意的是，还有一个针对外部链接的每个用户的设置：

[https://meta.discourse.org/my/preferences/interface](https://meta.discourse.org/my/preferences/interface)

![image](https://global.discourse-cdn.com/meta/original/4X/7/6/e/76e95d0e24dccb9f25db1111a6d1bb63d1bbd785.png)

---

<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:** [2022年十二月27日 16:31 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/7 "2022-12-27T16:31:50Z")

</div>

> [@Canapin](#):
>
> 除非我有什么误解

你没有误解。但在 Hub 上“在新标签页中打开”不起作用，我懒得在 Safari 上查看。但当我右键单击（即长按）时，该打开命令如预期般在浏览器中打开。苹果在各处都有自己的解决方案 😉

> [@Canapin](#):
>
> 你编辑了你的消息

我添加了闭合的 `</a>`，但那是在我发布答案后不久（我想在这里放一个思考的表情符号，但这里没有表情符号；奇怪）。

---

<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:** [2022年十二月27日 16:37 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/8 "2022-12-27T16:37:04Z")

</div>

> [@Jagster](#):
>
> 但在 Hub 中在新标签页打开不起作用，我懒得在 Safari 中检查。但当我右键单击（即长按）时，该打开命令如预期般在浏览器中打开。苹果在所有地方都有自己的解决方案 😉

链接如何处理由开发者决定。

在 DiscourseHub 应用的 iOS 设置中，有一个切换开关可以决定是在应用内打开还是在默认浏览器中打开。

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/7/f/37f86f6b9eb411a86da1a91e92e66d19f2be56dd.jpeg)

---

<div class="post-metadata">

**Author:** ![Beca\_Lewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/beca_lewis/32/286210_2.png) [@Beca\_Lewis](https://meta.discourse.org/u/Beca_Lewis)\
**Post date:** [2022年十二月27日 16:37 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/9 "2022-12-27T16:37:09Z")

</div>

谢谢你的帮助！

---

<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:** [2022年十二月27日 16:42 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/10 "2022-12-27T16:42:02Z")

</div>

确实如此。但即使禁用了外部链接，它们还是会在 Safari 中打开。其他任何情况都会很奇怪。

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月1日 15:56 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/11 "2023-01-01T15:56:05Z")

</div>

If you put a space before the link (or any other characters), Discourse will not draw the preview:

[How to stop links from showing the site](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955)

This applies to internal and external links.

Without the space:

> [@How to stop links from showing the site](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955):
>
> Is there a way to put a link in a message or post and NOT have it show the page? When I put a link to a page that is on my membership site, instead of displaying the link, it shows a message that the user is not logged in - which is confusing. I’d like to post a link, but not have it show the website itself. And if it’s possible to make that link open into another tab that would be awesome too.

---

<div class="post-metadata">

**Author:** ![Beca\_Lewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/beca_lewis/32/286210_2.png) [@Beca\_Lewis](https://meta.discourse.org/u/Beca_Lewis)\
**Post date:** [2023年一月1日 16:21 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/12 "2023-01-01T16:21:40Z")

</div>

谢谢！我还发现将链接放在“\<”和“\>”之间也有效。

---

<div class="post-metadata">

**Author:** ![Loki](https://avatars.discourse-cdn.com/v4/letter/l/3be4f8/32.png) [@Loki](https://meta.discourse.org/u/Loki)\
**Post date:** [2023年一月1日 17:07 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/13 "2023-01-01T17:07:05Z")

</div>

是的，它确实。我只是提到了前导空格，因为它输入起来更快……只需空格、粘贴即可。😃

---

<div class="post-metadata">

**Author:** ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)\
**Post date:** [2023年一月1日 18:46 UTC](https://meta.discourse.org/t/how-to-stop-links-from-showing-the-site/249955/14 "2023-01-01T18:46:01Z")

</div>

你好，

关于外部链接的另一个提示 🙂 您也可以按域名阻止 onebox。如果您想为整个域名阻止它，这是一个很好的解决方案。

有一个站点设置：`blocked onebox domains`，您可以在其中添加不希望 onebox 生成的域。

例如：我添加了 `wikipedia.org`。

 ![Screenshot_20230101_191908](https://global.discourse-cdn.com/meta/original/4X/9/6/0/9601f4bd2ca53eeaef47cafb0a50f55ec397f4e3.jpeg)

这样它就不会为维基百科链接生成 onebox。

 ![Screenshot_20230101_192639](https://global.discourse-cdn.com/meta/original/4X/3/2/5/3258a91b8a0ffd9a3b504e9b868f395fb21fb341.jpeg)

 ![Screenshot_20230101_192519](https://global.discourse-cdn.com/meta/original/4X/b/b/1/bb10963c9c407ec39c92cb65d8d0f83420d76f8f.jpeg)
