Answers.Body: <p>How about just using the replace filter?</p>
  
  <pre><code>{% set text = "A small boat surrounds a large ​island​​" %}
  
  {% set linkedText = text|replace({'boat':'&lt;a href="/whatever"&gt;boat&lt;/a&gt;'}) %}
  
  {{ linkedText|raw }}&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>That works.  </p>
  
  <p>In theory there should be a way to do it with parseRefs too, but my initial test isn't working yet:</p>
  
  <pre><code>{% set refText = text|replace({'boat':'&lt;a href="{entry:11102:}"&gt;boat&lt;/a&gt;'}) %}
  
  {% set parsedText = refText|parseRefs %}
  
  {{ parsedText|raw }}
  </code></pre>
  
  <p>...which leaves an unparsed ref tag so far.  I'm just heading out of the office but maybe a simple replace as above is enough to get you started?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-10T07:26:46.247Z
Answers.LastActivityDate: 2016-08-10T07:26:46.247Z
Answers.UserDisplayName: Jeremy Daalder
Answers.Body: <p>Assuming you only need this to work on the front end of your site (i.e., you don't actually need to see the links inside the Redactor field in the control panel), something like this might do the trick:</p>
  
  <pre><code>{# Get the rich text content #}
  {% set text = entry.richTextField %}
  
  {# Get all entries that could possibly be linked #}
  {% set entries = craft.entries.section('someSection').limit(null) %}
  
  {# Loop through entries, replacing any words matching entry titles with a link #}
  {% for entry in entries #}
      {% set text = text|replace({(entry.title|lower):'&lt;a href="'~entry.url~'"&gt;'~entry.title|lower~'&lt;/a&gt;'}) %}
  {% endfor %}
  
  {# Render the text #}
  {{ text|raw }}
  </code></pre>
  
  <p>Note that there are several possible issues with the above:</p>
  
  <ul>
  <li>You might see performance issues if you have a lot of entries to match (consider using the <a href="https://craftcms.com/docs/templating/cache" rel="nofollow"><code>{% cache %}</code></a> tag)</li>
  <li>Lower/uppercase and capitalization issues are difficult to deal with (the above example only matches lowercase words and phrases to the entry titles)</li>
  <li>Words and phrases with HTML tags inside won't match, i.e. "something <strong>something</strong>" wouldn't match the entry title "Something something"</li>
  <li>Entries can have identical titles, so if you have more than one entry called "Something something" only the last one will be linked</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-10T09:55:34.660Z
Answers.LastActivityDate: 2016-08-10T09:55:34.660Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>Has anyone implemented auto linking of words within a redactor field? For example, a rich text field would contain this:</p>
  
  <blockquote>
    <p>​<em>A small <strong>boat</strong> surrounds a large ​<strong>island</strong>​</em>​</p>
  </blockquote>
  
  <p>In a channel there are entries titled <strong>boat</strong> and <strong>island</strong>. I would like to automatically link to these without the editor having to manually link them. </p>
  
  <p>Not sure how approach this so any hints to get me on my way are most appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-10T06:02:53.060Z
Comments.Text: Are all the entries titled with a single word?
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Tags: <redactor><search><richtext><replace>
Title: Automatically link to entries in rich text field
ThreadText: # Automatically link to entries in rich text field
  
  (Asked by: username_0 on 2016-08-10)
  
  Has anyone implemented auto linking of words within a redactor field? For example, a rich text field would contain this:
  
  > ​*A small **boat** surrounds a large ​**island**​*​
  
  In a channel there are entries titled **boat** and **island**. I would like to automatically link to these without the editor having to manually link them.
  
  Not sure how approach this so any hints to get me on my way are most appreciated.
  
  **Tags:** redactor, search, richtext, replace
  
  > **Comments:**
  > **username_1**: Are all the entries titled with a single word?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-08-10. Score: 3
  
  How about just using the replace filter?
  
  ```
  {% set text = "A small boat surrounds a large ​island​​" %}
  
  {% set linkedText = text|replace({'boat':'<a href="/whatever">boat</a>'}) %}
  
  {{ linkedText|raw }}<br><br>
  
  ```
  
  That works.
  
  In theory there should be a way to do it with parseRefs too, but my initial test isn't working yet:
  
  ```
  {% set refText = text|replace({'boat':'<a href="{entry:11102:}">boat</a>'}) %}
  
  {% set parsedText = refText|parseRefs %}
  
  {{ parsedText|raw }}
  
  ```
  
  ...which leaves an unparsed ref tag so far. I'm just heading out of the office but maybe a simple replace as above is enough to get you started?
  
  
  ---
  
  ### Answer by username_1 on 2016-08-10. Score: 1
  
  Assuming you only need this to work on the front end of your site (i.e., you don't actually need to see the links inside the Redactor field in the control panel), something like this might do the trick:
  
  ```
  {# Get the rich text content #}
  {% set text = entry.richTextField %}
  
  {# Get all entries that could possibly be linked #}
  {% set entries = craft.entries.section('someSection').limit(null) %}
  
  {# Loop through entries, replacing any words matching entry titles with a link #}
  {% for entry in entries #}
      {% set text = text|replace({(entry.title|lower):'<a href="'~entry.url~'">'~entry.title|lower~'</a>'}) %}
  {% endfor %}
  
  {# Render the text #}
  {{ text|raw }}
  
  ```
  
  Note that there are several possible issues with the above:
  
  * You might see performance issues if you have a lot of entries to match (consider using the [`{% cache %}`](https://craftcms.com/docs/templating/cache) tag)
  * Lower/uppercase and capitalization issues are difficult to deal with (the above example only matches lowercase words and phrases to the entry titles)
  * Words and phrases with HTML tags inside won't match, i.e. "something **something**" wouldn't match the entry title "Something something"
  * Entries can have identical titles, so if you have more than one entry called "Something something" only the last one will be linked
  
  
  ---
  
  