# Auto-Linkify Words

**URL:** https://meta.discourse.org/t/auto-linkify-words/82193
**Category:** Theme component
**Tags:** official, linkify-words
**Created:** [5 maart 2018 om 07:16 UTC](https://meta.discourse.org/t/auto-linkify-words/82193 "2018-03-05T07:16:06Z")
**Posts on this page:** 17
**Page:** 12

<div class="post-metadata">

### Author: ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)
#### Post date: [5 oktober 2023 om 21:33 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/234 "2023-10-05T21:33:29Z")

</div>

> [@sam](#):
>
> I would like to clarify first, why are users using the component vs built in watched words?

Likely because folks don’t know, I got referred to this post looking for solution to [link search words to topics](https://meta.discourse.org/t/linked-forcing-search-keywords-to-specific-topics-posts/281205) and my default reaction was to install this component. I didn’t even realize that `watched words` existed. It’s so cool how much I learn about discourse every time I try to optimize it.

If you’re okay I’m going to edit the first post to let folks know that watched words exist and may be an out of box fit. Also this theme is marked as official so if it’s a duplicate of `watched words` maybe consider depreciating it or indicating it on the first post.

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [8 november 2023 om 15:29 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/237 "2023-11-08T15:29:58Z")

</div>

I have a feature request. It would be wonderful if we could have this only apply to body text and not headings, it looks silly when one word in a heading is linked:

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/9/8/898ef208b4badb287dcaf46e0a9d0e676ac5084c.jpeg)

---

<div class="post-metadata">

### Author: ![cmdntd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cmdntd/32/192008_2.png) [@cmdntd](https://meta.discourse.org/u/cmdntd)
#### Post date: [12 november 2023 om 03:09 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/238 "2023-11-12T03:09:28Z")

</div>

Sometimes, there are too many same linkify words in long content.  
I think it be better to display in only first one in content. The others could be bold, instead of links.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)
#### Post date: [20 november 2023 om 22:19 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/239 "2023-11-20T22:19:32Z")

</div>

Seems like you should be able to do that by adding `h1` `h2` and others to the " excluded tags" setting in the extension, no?

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [20 november 2023 om 23:14 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/240 "2023-11-20T23:14:24Z")

</div>

Thanks Matt, I think you mean `excluded classes`, which I somehow didn’t notice before, but unfortunately these are not working so I guess this is a bug report rather than a feature request.

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/4/2/d4227846d4e140e9ba953d1d7c0ed1e22defe85e.jpeg)

The screenshot I posted earlier is an h2 with class of anchor.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)
#### Post date: [21 november 2023 om 04:28 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/241 "2023-11-21T04:28:32Z")

</div>

No, I meant tags. Those are HTML tags, not discourse topic tags, as I understand it.

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [21 november 2023 om 04:43 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/242 "2023-11-21T04:43:28Z")

</div>

Indeed, you are correct! Thank you Matt. I was too fixated on tags being discourse tags. I appreciate your help.

---

<div class="post-metadata">

### Author: ![hoangphuctran93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hoangphuctran93/32/290976_2.png) [@hoangphuctran93](https://meta.discourse.org/u/hoangphuctran93)
#### Post date: [29 maart 2024 om 01:39 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/245 "2024-03-29T01:39:06Z")

</div>

Can you tell me if it is possible to import multiple linkify words at the same time or use the API to connect to a management file on Google Sheets? I have an idea about using this TC in managing and creating multiple glossaries

---

<div class="post-metadata">

### Author: ![toanvoc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toanvoc/32/423586_2.png) [@toanvoc](https://meta.discourse.org/u/toanvoc)
#### Post date: [9 augustus 2024 om 13:09 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/246 "2024-08-09T13:09:27Z")

</div>

I find this theme component interesting and useful, but it links keywords too many times, attaching it correctly is only attaching the first word to reduce spam.

I sent an attached image and it repeats 3 times for 1 keyword. I hope this part will be fixed in the next update.

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/6/4/46422dc3334a4a1fe58653aaca759c8e7d7c2618.png)

---

<div class="post-metadata">

### Author: ![joo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joo/32/334852_2.png) [@joo](https://meta.discourse.org/u/joo)
#### Post date: [9 oktober 2024 om 03:08 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/247 "2024-10-09T03:08:20Z")

</div>

Hi! Thanks for the great plugin!

Quick question: can it still match words even if they don’t have spaces before or after them? I remember it used to match without needing spaces around the word.

---

<div class="post-metadata">

### Author: ![Carlo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlo/32/79036_2.png) [@Carlo](https://meta.discourse.org/u/Carlo)
#### Post date: [12 november 2024 om 09:22 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/248 "2024-11-12T09:22:33Z")

</div>

Hi there, is there a way to set links to target=“\_self”? By default, they all open in a new tab (target=“\_blank”), but I couldn’t find any setting to change this.

Tks a lot

---

<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: [12 november 2024 om 15:42 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/249 "2024-11-12T15:42:17Z")

</div>

> [@Carlo](#):
>
> is there a way to set links to target=“\_self”?

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

and search for `Open all external links in a new tab`. It defaults to off because that’s Best Practice. You can use `/admin/site_settings/category/all_results?filter=external%20links` to change the default for all users.

---

<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: [12 november 2024 om 15:56 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/250 "2024-11-12T15:56:04Z")

</div>

The preference works for normal links in the post, but for me those created by this component always open in a new tab. Does the preference change the behavior of links created by this component for you? I wonder what I am missing.

---

<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: [12 november 2024 om 16:04 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/251 "2024-11-12T16:04:08Z")

</div>

> [@Moin](#):
>
> The preference works for normal links in the post, but for me those created by this component always open in a new tab.

Oops. Sorry. I didn’t notice that. You’re right. It’s hard-coded to blank:

> <https://github.com/discourse/discourse-linkify-words/blob/main/javascripts/discourse-linkify/initializers/initialize-discourse-linkify.js#L36>

Sounds like a reasonable feature request to me.

Wait. I was **really** not paying attention. If there is going to be a hard-coded option, ignoring the user preferences, it should be to open in the **same window**. That’s what the best practice is. And if the linkified links go to Discouse and not somewhere external then it’s an even more unexpected behavior that they’d open in a new tab.

---

<div class="post-metadata">

### Author: ![Carlo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlo/32/79036_2.png) [@Carlo](https://meta.discourse.org/u/Carlo)
#### Post date: [12 november 2024 om 17:27 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/252 "2024-11-12T17:27:31Z")

</div>

I’ve tried to fix this with JavaScript (code below), but it only works occasionally. I believe Ember.js might be conflicting with it. So it’s not ideal

```plaintext
<script>
	window.addEventListener("load", function() {
		document.querySelectorAll("a.linkify-word.no-track-link").forEach(function(link) {
			link.removeAttribute("target");
		});
	});
</script>

```

---

<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: [12 november 2024 om 17:33 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/253 "2024-11-12T17:33:14Z")

</div>

A better solution would be to fork the theme component and/or submit a PR.

---

<div class="post-metadata">

### Author: ![Carlo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlo/32/79036_2.png) [@Carlo](https://meta.discourse.org/u/Carlo)
#### Post date: [13 november 2024 om 07:52 UTC](https://meta.discourse.org/t/auto-linkify-words/82193/254 "2024-11-13T07:52:47Z")

</div>

I don’t know what it’s worth, but I asked ChatGPT for a way to add a backend checkbox to toggle between target=“\_self” and target=“\_blank”. Here’s what it suggested:

Code for settings.yaml:

```plaintext
self_target:
  type: bool
  default: false
  client: true

```

Code for initialize-discourse-linkify.js:

```plaintext
  let createLink = function (text, url) {
	let link = document.createElement("a");
	link.innerHTML = text;
	link.href = url;
	link.rel = "nofollow";
	link.target = settings.self_target ? "_self" : "_blank"; // Use the admin setting here
	link.className = "linkify-word no-track-link";
	return link;
  };

```

Do you think this might work ?

[Vorige pagina](https://meta.discourse.org/t/auto-linkify-words/82193.md?page=11)
