Linkify words in post

(Daniel Hollas) #110

This should already work via regex, try this input:


See this part of OP

Let me know if I should make that description clearer.

(Daniel Hollas) #111

Whoops, I totally misread what you’re trying to do. Indeed, if you want to have case sensitive words, just make them into regexes i.e. /Discourse/ , without the i modifier. Not sure we need extra site setting if the workaround is so simple?

(Joffrey Jaffeux) split this topic #112

A post was split to a new topic: Re-categorise lot of topics with bulk action

(jrgong) #113

@sam It has been discussed before here: managing the list via CSV file

I am now managing a large set of linkified terms and links in two locations: The linkify settings + a spreadsheet (as backup). It’s a hassle to maintain the list in those 2 locations and keep it in sync when entering new data.

Is there any way we gonna see a feature to manage those settings lists via CSV?

I would love to get an option to simply point to an external CSV URL where the list is pulled from either manually or via cronjob.

(Régis Hanol) #114

Strongly suggest you put together a budget and ask in #marketplace for someone to build this for you :wink:


I found a strange bug. When you have 0 linked words (you must delete the default words to see that) you’re Discourse turns white - It’s a blank page and you can’t use it anymore.

I had to use safe mode to get things back on track.

(Daniel Hollas) #116

This is strange, I think I fixed that bug. Do you have the most up-to-date version?


I updated yesterday, I’m on Discourse v2.3.0.beta4 +20. Here is the error:

Uncaught TypeError: Cannot read property 'trim' of undefined Url: Line: 1 Column: 42780 Window

TypeError: Cannot read property 'trim' of undefined
    at Array.forEach (<anonymous>)
    at z (
    at Object.initialize (
    at e.each (
    at e.walk (
    at e.each (
    at e.topsort (
(Daniel Hollas) #118

Okay, thanks for the report, that error is useful. I’ll try to have a look next week.

(Azzaazeel) #119

Can you add the feature that shows only first keyword occurs in the topic. Thank you.

(Sam Saffron) #120

Interesting request, we have theme settings happy for a setting for this to be added

(jrgong) #121

Or even better: able to configure to linkify a keyword for the first n occurrences in a topic. :slight_smile:


The problem I see with this is that in long topics, one would lose the link when “arriving late”.

Maybe something like the <abbr> HTML tag, where the first occurrence uses a title attribute, then the following ones do not need it, and let the browser interpret it.

With linkified words, the first (few) links in the current view of the current user would be linkified, then only “titled” – maybe clickable, but not displayed as links to avoid information overflow.

1 Like
(Daniel Hollas) #123

This should now be fixed, thanks again for reporting!

I’ve looked into this and it would be tricky to implement without a major rewrite. The current code works per individual paragraphs. Moreover, it works backwards from the last one to the first, so the code would probably need to do an additional forward pass to remove the extra links. This is further complicated by dynamic loading of posts. Not sure all this is worth it for this feature.

What I can do with a bit of code refactor is to remove the duplicities within an individual paragraph. This seems like a reasonable defualt that perhaps does not even require an extra theme setting.

EDIT: @hellekin heh, you were just a bit faster :smiley:

Yeah, this would also be tricky to ensure if you land in the middle of a topic.


Yes, It’s all good now. Thanks! :+1:t2:

1 Like
(Daniel Hollas) #125

This is now merged. Only the first instance of a word in a paragraph will get autolinked (but if you match words using regexes all instances will be autolinked as before).

It did require a rather large refactor during which I fixed some corner cases, but it is possible I introduced some others so please test carefully after you update to latest. @Southpaw I know you use this theme extensively so if you could confirm everything looks OK that would be great!

FYI: @azzaazeel

(Southpaw) #126

Hi @danekhollas,

Everything looks good this morning, and the one-link-per-paragraph limit is an appreciated upgrade. I’ve alerted my power users that there has been an update, and we’ll certainly let you know if we see any new oddness arise.

(Sat) #127

Hi @sam, I do see if there are more than one word in a sentence for linkify then it only shows hyperlink for the first word. is this limitation?

(Régis Hanol) #128

It’s a feature. See 2 posts up :arrow_up:

And like @danekhollas says, if you want to linkify all occurences, you can use regexes instead.

(Sat) #129

Ok, thank you! got it now