# External domain link blocklist

**URL:** https://meta.discourse.org/t/external-domain-link-blocklist/287255
**Category:** Feature
**Created:** [December 2, 2023, 6:47am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255 "2023-12-02T06:47:40Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [December 2, 2023, 6:47am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/1 "2023-12-02T06:47:40Z")

</div>

Is there a way to prevent a specific domain from being linked at all?

The use-case is the following: a user keeps responding to any topic with links to their website, which is not necessarily bad nor dangerous, but the result is that all conversations feel hijacked and spammy. After insisting several times with this user, the posting pattern persists. Note that the `rel="nofollow"` does not seem to prevent such behavior.

I’m thinking that removing the links entirely, or even preventing posting when the domain appears may give an incentive to contribute to the conversation itself for its own sake rather than to spit out external links all the time.

Maybe there are other, non-technical ways to address this issue, but I can see it as a potentially recurring issue across forums.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [December 2, 2023, 6:55am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/2 "2023-12-02T06:55:45Z")

</div>

A quick solution may be to downgrade the user so that he cannot post any links at all.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [December 2, 2023, 6:56am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/3 "2023-12-02T06:56:06Z")

</div>

You could put the link itself on the `/admin/customize/watched_words/action/block` list.

---

<div class="post-metadata">

### Author: ![jericson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jericson/32/116215_2.png) [@jericson](https://meta.discourse.org/u/jericson)
#### Post date: [December 4, 2023, 5:54am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/4 "2023-12-04T05:54:54Z")

</div>

> [@hellekin](#):
>
> The use-case is the following: a user keeps responding to any topic with links to their website, which is not necessarily bad nor dangerous, but the result is that all conversations feel hijacked and spammy.

@Firepup650’s watched words suggestion is useful when a variety of people are posting links to a small number of spammy sites. Definitely a useful tool to have. In this case it seems like you have a user who is pushing the limits of what’s socially acceptable. You might want to consider a [self-promotion policy](https://meta.discourse.org/t/how-do-you-handle-moderate-commercial-members/285761/5) as well. That might solve the problem without bringing in the block, which might feel heavy-handed.

An inevitable problem with blocklists is that persistent offenders find ways around it. A well-formed policy can create a community norm that channels users into more productive activity. And if not, blocking still remains a potential solution. 😉

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [December 6, 2023, 1:35am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/5 "2023-12-06T01:35:58Z")

</div>

Indeed either block the domain in watched words or even have a bit of minor fun. And have it replace the url with something like “Oops NoGo”

---

<div class="post-metadata">

### Author: ![Isambard](https://avatars.discourse-cdn.com/v4/letter/i/858c86/32.png) [@Isambard](https://meta.discourse.org/u/Isambard)
#### Post date: [January 23, 2025, 11:39am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/6 "2025-01-23T11:39:55Z")

</div>

I had the same question also for short domain names e.g. if you want to block “[ent.com](http://ent.com)” you also need to avoid it blocking “[content.com](http://content.com)”.

---

<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: [January 23, 2025, 12:07pm UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/7 "2025-01-23T12:07:22Z")

</div>

> [@Isambard](#):
>
> if you want to block “[ent.com](http://ent.com)” you also need to avoid it blocking “[content.com](http://content.com)”.

Having `ent.com` as a watched word doesn’t get triggered with `content.com`. Or do I misunderstand you?  
Also you can use regular expressions to fine tune watched words for URLs you don’t want see posted.

---

<div class="post-metadata">

### Author: ![Isambard](https://avatars.discourse-cdn.com/v4/letter/i/858c86/32.png) [@Isambard](https://meta.discourse.org/u/Isambard)
#### Post date: [January 23, 2025, 2:43pm UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/8 "2025-01-23T14:43:45Z")

</div>

thanks so if you put “[ent.com](http://ent.com)” would it block all variations of “http(s)://ent.com/[url]?” where url is an arbitrary sequence?

> [@Canapin](#):
>
> Also you can use regular expressions to fine tune watched

OK. I think I need to use regexp

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [January 25, 2025, 7:21pm UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/9 "2025-01-25T19:21:21Z")

</div>

Thank you for your replies. I remember having tried various ways of watched words but links do not get unlinked AFAIK. Can someone provide a working example?

---

<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: [January 25, 2025, 7:33pm UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/10 "2025-01-25T19:33:00Z")

</div>

A very basic theme component (courtesy of 🤖) using a hardcoded domain list:

```js
<script type="text/discourse-plugin" version="0.8.25">
  api.decorateCookedElement((element) => {

    const domainsToUnlink = ["example.com", "specificdomain.com"];

    const links = element.querySelectorAll("a");

    links.forEach((link) => {
      const url = new URL(link.href);
      if (domainsToUnlink.includes(url.hostname)) {
        const textNode = document.createTextNode(link.textContent);
        link.replaceWith(textNode);
      }
    });
  }, { id: "unlink-specific-domains" });
</script>

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/8/2/3827aca3ae91637809553ae4b7dcd6980960406a.png)

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [January 26, 2025, 12:15am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/11 "2025-01-26T00:15:53Z")

</div>

Just to get my brain on this.

The script converts a specified link to unclicksble plain text version of link?

Could it be modified to replace link say with “Forbidden” maybe as a link to a rules post with a list of not allowed domains?

---

<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: [January 26, 2025, 12:33am UTC](https://meta.discourse.org/t/external-domain-link-blocklist/287255/12 "2025-01-26T00:33:59Z")

</div>

Yes for both questions 🙂
