# Auto-Linkify Words

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

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [September 24, 2020, 9:41am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/190 "2020-09-24T09:41:17Z")

</div>

@danekhollas

Unfortunately I still have the issue. I tried changing the order of the regexes in the theme settings, yet the “shorter” entry is still triggered first.

---

<div class="post-metadata">

### Author: ![Marrisse\_Asuncion](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marrisse_asuncion/32/199404_2.png) [@Marrisse\_Asuncion](https://meta.discourse.org/u/Marrisse_Asuncion)
#### Post date: [November 13, 2020, 8:45pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/191 "2020-11-13T20:45:53Z")

</div>

Hello @jrgong! Were you able to do bulk uploads using a CSV file? Trying to figure it out but I’m not quite sure where to click. I am not a developer btw 😃

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [November 17, 2020, 12:57pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/192 "2020-11-17T12:57:19Z")

</div>

I am using this 🙂

[https://meta.discourse.org/t/discourse-linkify-google-sheets/163985/4](https://meta.discourse.org/t/discourse-linkify-google-sheets/163985/4)

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [February 16, 2021, 3:50am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/193 "2021-02-16T03:50:59Z")

</div>

> [@jrgong](#):
>
> Unfortunately I still have the issue.

So do we. I note that:

```plaintext
discourse,https://discourse.org
discourse meta,https://meta.discourse.org
meta discourse,https://meta.discourse.org

```

Gives us:

[discourse](https://discourse.org/)  
[discourse meta](https://meta.discourse.org/)  
meta [discourse](https://discourse.org/)

The order that these are in the Theme Settings (and presumably the database beneath) doesn’t seem to make a difference. Rather, if you extend an existing linkified word, it will pick up the difference. If you add a word in front, it doesn’t.

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [February 16, 2021, 7:08pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/194 "2021-02-16T19:08:59Z")

</div>

Hmm, that’s a bit strange. You’re right, the order in the settings shouldn’t matter, because we sort the words by length:

> <https://github.com/discourse/discourse-linkify-words/blob/a516d488dc23f401a7062808b98a231af9a16ef1/javascripts/discourse-linkify/lib/utilities.js.es6#L99>

Not sure how much time should be invested in this since AFAIK this feature is being ported to Discourse core.

---

<div class="post-metadata">

### Author: ![Paracelsus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paracelsus/32/164912_2.png) [@Paracelsus](https://meta.discourse.org/u/Paracelsus)
#### Post date: [February 18, 2021, 7:24am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/195 "2021-02-18T07:24:37Z")

</div>

Hi,

Just noticed that the linkified words don’t have that click counter as other links have (which would be a nice feature to have, in my opinion). Is it on purpose or just a bug?

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [March 18, 2021, 3:22am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/196 "2021-03-18T03:22:54Z")

</div>

can this be restricted to specific categories/tags so that a post would have to be in the category or tagged to generate links?

---

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [March 30, 2021, 10:21pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/197 "2021-03-30T22:21:46Z")

</div>

Is it possible to specify a title for the link? So “ghost” becomes “ghost (see warning!)”?

Possibly using markdown link syntax:

`ghost,[ghost (see warning!)](https://warning.example.com)`

Or specifying the title as a third parameter:

`ghost,https://warning.example.com,ghost (see warning!)`

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [April 9, 2021, 10:17pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/198 "2021-04-09T22:17:04Z")

</div>

@Paracelsus the click counter is not supported in this theme, sorry.

Not really a bug, the theme is only a JavaScript code running in your browser. It doesn’t talk to the server so there’s no way to store the number of clicks.

---

<div class="post-metadata">

### Author: ![RickThrivingNow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rickthrivingnow/32/119287_2.png) [@RickThrivingNow](https://meta.discourse.org/u/RickThrivingNow)
#### Post date: [June 17, 2021, 5:51pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/199 "2021-06-17T17:51:30Z")

</div>

Now in discourse under replace words:  
/admin/customize/watched\_words/action/replace

If I just enter the word and then just put the URL without any markdown, it works! So that is how to get it to work without the autolink theme component.

(Whereas in the theme component you put the word/phrase then a comma then the link to use, in watched word replace you enter the word in one field and JUST the link in another… do not try to enter markdown in the replacement string like I originally tried.)

---

<div class="post-metadata">

### Author: ![Kuro22](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuro22/32/261055_2.png) [@Kuro22](https://meta.discourse.org/u/Kuro22)
#### Post date: [March 19, 2022, 1:51pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/200 "2022-03-19T13:51:25Z")

</div>

Hey, this’s a great component! Thanks for having done this.

But a little problem there, it seems that the linkification requires a space after the specific word, so the component is not working well in Chinese and Japanese (maybe also Korean? I don’t know this language) Discourse instances.

I’m a native speaker of Chinese, and I speak Japanese too. In Chinese, it happens that people use some fixed borrowed words in letters, like Apple, Office, BB (Blackboard), DNA, etc., whose translation is quite rarely used in the familiar language. And we usually don’t add a space before/after this kind of word when it’s surrounded by Chinese, in informal writing.

This is an example:

> 你会用Office吗？  
> Do you know how to use Office suite?

It’s similar in Japanese.

> 革新に満ちたAppleの世界へようこそ。(copied from Apple Japan official site)  
> Welcome to the world of Apple, which is full of revolutions.

I’m aware that it might be a lot of work to adapt this component for these two languages, cause this might lead to unintended linkifications in languages using the alphabet. So, just pointing out the existence of a small imperfection. Appreciate again this great idea of making this component. 😺

---

<div class="post-metadata">

### Author: ![Drew-ART](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@Drew-ART](https://meta.discourse.org/u/Drew-ART)
#### Post date: [March 24, 2022, 1:46am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/201 "2022-03-24T01:46:30Z")

</div>

This works great. Is it possible to run it retroactively, or do you need to search all the links manually and change them?

---

<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: [March 24, 2022, 10:17am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/202 "2022-03-24T10:17:49Z")

</div>

You should be able to rebake those posts. You can click the wrench and rebuild html. When you s they works then you can search for how to rebake matching posts rake task.

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [March 24, 2022, 10:31am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/203 "2022-03-24T10:31:53Z")

</div>

Actually, this theme linkifies posts dynamically when they are loaded in the browser so no need to do anything. 🙂

---

<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: [March 24, 2022, 12:43pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/204 "2022-03-24T12:43:37Z")

</div>

> [@danekhollas](#):
>
> this theme linkifies posts dynamically when they are loaded in the browser

Oh. Very cool. I hadn’t realized, but that makes sense.

---

<div class="post-metadata">

### Author: ![emyoulation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/emyoulation/32/165545_2.png) [@emyoulation](https://meta.discourse.org/u/emyoulation)
#### Post date: [March 25, 2022, 9:18pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/205 "2022-03-25T21:18:23Z")

</div>

> [@John\_Waltrip1](#):
>
> I’ve been thinking of creating a glossary in our forum, and this seems like a great way to make it actually useful. I’m wondering how others may have implemented glossaries for their forum? Did you put each word onto it’s own topic? The entire glossary into a single topic? Something else?

Our FOSS genealogy software glossary was too extensive for a Posting or Linkifying.

If we had just Linkified each Glossary term, then every posting would drown in a sea of blue links. Users would be likely to stop clicking links. And we wanted an audit trail for the Glossary.

So I linkified “Gramps Glossary” to that article in our [MediaWiki](https://mediawiki.org/wiki/MediaWiki)-powered wiki. And now use an annotation like “_(see `[glossary term]` in the [Gramps Glossary](https://gramps-project.org/wiki/index.php/Gramps_Glossary))_”

(We have a 2nd _Genealogy Glossary_ for terminology that is generic to the Genealogy subject matter rather than specific to our software.)

---

<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: [May 9, 2022, 12:42am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/206 "2022-05-09T00:42:09Z")

</div>

Has something been done to allow pipes?

I’m currently using this as a workaround:  
 ![image](https://global.discourse-cdn.com/meta/original/4X/7/0/e/70ea59f0dba3c167af3794fc8ebe915d394387f2.png)

* * *

Also, is there a way to exclude a world from being linkified when inside a grand-grand-[…]children of an **excluded class**?  
I’m building a forum with a Documentation category, and I don’t want linkified words in it because it would be redundant: words in other categories will be linkified and will link to topics in this documentation category.  
Plus, linkified words open in a new window.

So, this didn’t work:  
 ![image](https://global.discourse-cdn.com/meta/original/4X/8/e/6/8e6dfda82b59ff9eb640c5071b6929306c46adf0.png)

Here’s an example of the issue I’m facing. This is the part of a text inside a documentation topic.

 ![image](https://global.discourse-cdn.com/meta/original/4X/6/9/e/69e81964e12e9dfa5fad41982e5d3dd10e2a7545.jpeg)

If I click **22° halo** , it will open a page that links to… The same page, at the same place.  
I can exclude words in titles, especially because it contains a [table of content](https://meta.discourse.org/t/discotoc-automatic-table-of-contents/111143), but the following paragraphs don’t have any specific class. They are regular paragraphs.

* * *

Maybe the **excluded class** setting could accept CSS selectors?  
For example, `d-toc-cooked > *`

* * *

edit: Also I fail to understand why this doesn’t work since my word is a direct child of an excluded class:

![image](https://global.discourse-cdn.com/meta/original/4X/5/b/7/5b74ab625d4676e33aebf3c9cbe825e3d0f22c44.png)

The “22° Halo” is still linkified:

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/1/b/71b9ede267725c4f07d71ea6c10a3f5f6fbd18e1.png)

```xml
<h3 id="toc-h3-22-halo" data-d-toc="toc-h3-22-halo" class="d-toc-post-heading">
    <a name="h-22-halo-7" class="anchor" href="#h-22-halo-7"></a>
    <a href="https://discourse.canapin.com/t/ice-halos-information-and-list/28#h-22-halo-7" rel="nofollow" target="_blank" class="linkify-word no-track-link">22° Halo</a>
</h3>

```

Is that because the table of content HTML code could be generated _after_ the “linkification”?

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [May 9, 2022, 1:16am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/207 "2022-05-09T01:16:39Z")

</div>

> [@Canapin](#):
>
> Is that because the table of content HTML code could be generated _after_ the “linkification”?

Yeah, that’s probably the issue here, both of these are JavaScript components so you have a race condition and the result will depend on which one runs first.

---

<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: [May 17, 2022, 9:52pm UTC](https://meta.discourse.org/t/auto-linkify-words/82193/208 "2022-05-17T21:52:54Z")

</div>

I [added a class in the HTML allowlist](https://meta.discourse.org/t/what-are-the-different-ways-to-customize-content-inside-a-post-custom-attributes-and-such/226747/6) so I circumvented the issue.

However, being able to have a button **excluded attributes** could allow more flexibility to prevent linkify words, using the build-in `data-(anything)` HTML attribute since it’s allowed by default in Discourse.

Example:  
`<span data-nolinkify> text </span>` → text

Would a push request be accepted if I manage to add this to the theme component?

---

<div class="post-metadata">

### Author: ![md-misko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/md-misko/32/126315_2.png) [@md-misko](https://meta.discourse.org/u/md-misko)
#### Post date: [July 28, 2022, 9:59am UTC](https://meta.discourse.org/t/auto-linkify-words/82193/209 "2022-07-28T09:59:22Z")

</div>

> [@danekhollas](#):
>
> ```plaintext
> let leftWordBoundary = "(\\s|[\"\'\\([{]|^)";
> let rightWordBoundary = "([\"\':.;,!?…\\]})]|\\s|$)";
> 
> ```

This unfortunately prevents linkifying words that explicitly include any of these (especially `.`, which is handy in linking abbreviations like ID.1 or id2.5).

> [@sam](#):
>
> I think fundamentally we need a way of escaping pipes in lists, double pipe is sort of workable but requires a custom list parser, I suspect we just need to fix this at the source and allow site settings and theme settings to natively support this. I guess a workaround for now in this theme setting is to use a very rare char as the item separator like a rare Unicode seldom used and split on that

This is perhaps best fixed in core, but for the meantime here’s a PR that fixes the above issues:

[https://github.com/discourse/discourse-linkify-words/pull/21](https://github.com/discourse/discourse-linkify-words/pull/21)

Sample regex rule (will match `id1.1` to `id10.100` (including variations `id m.n`, `IDm.n` and `ID m.n`)

```plaintext
/(ID¦id)\s?(([1-9]¦10)\.([1-9]¦[1-9][0-9]¦100))/, https://example.com/id$2

```

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

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