<p>In Craft 3, you can set <code>"linkNewtab": true</code> and <code>"linkTarget": "_blank"</code> in your redactor config. This should default so the "Open in new tab" is automatically checked when creating links in a redactor field.</p>

<p><a href="https://imperavi.com/redactor/docs/settings/link/" rel="nofollow noreferrer">https://imperavi.com/redactor/docs/settings/link/</a></p>

CC BY-SA 4.0
2020-06-24T01:45:50.407Z
(Quibbling, but this of course only affects content in Redactor fields.  It does not result in _all_ external links opening in a new windows - which, again, may or may not be desirable, but the JS solution below is more general, if you do want this...)
Jeremy Daalder
CC BY-SA 4.0
2020-04-16T15:28:58.593Z
2020-04-16T15:28:58.593Z
Jeff Irwin
<p>Merits of doing this aside, I agree that JS is probably the easiest way to go here.</p>

<p>This code adds <code>target="_blank"</code> to all external links. </p>

<pre><code>// Make sure any offsite links (non js/mailtos) open in a new window
// from https://css-tricks.com/snippets/jquery/open-external-links-in-new-window/ - comment at end.
function openAllExternalLinksInANewWindow() {
    $(document).on('mousedown', 'a:not([href*="mailto:"],[href*="javascript"])', function(e) {
        var isInternalLink = new RegExp('/' + window.location.host + '/');
        if (!isInternalLink.test(this.href)) {
            $(this).attr('target', '_blank');
        }
    });
}
</code></pre>

CC BY-SA 3.0
2016-08-29T05:52:07.230Z
The only case in which I'd use target="_blank" is if opening a link would destroy some content the user has made on your site. In all other cases it's a very bad practise.
KnutSv
CC BY-SA 3.0
2016-08-30T08:42:03.927Z
Thanks Jeremy. I should've explained better in my question that yes I just wanted to add it just to external links. I'm surprised to see @KnutSv opposed to adding target="_blank". Could someone maybe point me to a discussion or study on the pros and cons of using it? Maybe I'm just naive on this one.
patrick.altair
CC BY-SA 3.0
2016-08-30T23:46:23.767Z
That's almost a holy war on the web :)  Persoanlly, I don't mind it for external links as we have a large, complex site, and people don't like losing their place on it...but I can also understand others views that it's always bad practise...

I'll edit my answer above to reflect the updated question.
Jeremy Daalder
CC BY-SA 3.0
2016-08-31T07:34:04.077Z
@patrick.altair People like to control for themselves whether a link should open in a new tab. I always hate when a site forces me to open external links in new tabs, just imagine if Google forced you to open all external links in new tabs. It's the same with your site, maybe they're just passing through? https://straightupcraft.com/craft-plugins/ does this when you go to the plugin page and it's always a pain in the ass to have to go back and close the original tab. Also less experienced users and blind users don't notice the new tab, just that they can no longer use the back button
KnutSv
CC BY-SA 3.0
2016-08-31T11:48:43.857Z
Ah ok, I can see both sides now. In my case its longform articles that link to products talked about in the articles. I wanted to open this is a new tab so readers don't lose their place in the article basically but this has made me reconsider. Thanks for the discussion guys!
patrick.altair
CC BY-SA 3.0
2016-08-29T00:19:31.517Z
2016-08-30T23:47:13.430Z
2016-08-30T23:47:13.430Z
Jeremy Daalder
<p>I've been trying to gather ideas from different places and still not sure how can I do it on Craft 2 having Redactor v2.13 or Redactor II. I looked into the redactor.js file (it's a huge file about 10k lines) and didn't find <code>linkTarget: '_blank'</code> to <code>linkTarget: '_blank'</code> May be it's because of difference in versions? There are similar mentions though such as</p>
<p><a href="https://i.sstatic.net/ilEr0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ilEr0.png" alt="Link Target settings Redactor 2.13" /></a></p>
<p><a href="https://i.sstatic.net/nLq3D.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nLq3D.png" alt="linkNewTab settings" /></a></p>
<p>I'd try to explore more and see how this goes. Just incase if someone has already gone through this.</p>

CC BY-SA 4.0
2021-06-01T13:22:47.800Z
2021-06-01T13:22:47.800Z
Anvar Jamal
<p>I have a website where by default I would like all external links to have the "open in a new tab" option to be selected by default. I'm wondering if this is possible either through craft or redactor? I came across <a href="https://github.com/fruitstudios/LinkIt" rel="nofollow">this</a> but think it may be overkill so I'm wondering if its possible without a plugin. </p>

CC BY-SA 3.0
2016-08-28T22:25:30.653Z
Guessing the easiest solution would be to add target="_blank" to all link elements with javascript. But the UX of doing this is awful. There is hardly any cases where target="_blank" is a good idea.
KnutSv
<redactor><link>
Is it possible to make links open in a new tab by default?
# Is it possible to make links open in a new tab by default?

(Asked by: username_0 on 2016-08-28)

I have a website where by default I would like all external links to have the "open in a new tab" option to be selected by default. I'm wondering if this is possible either through craft or redactor? I came across [this](https://github.com/fruitstudios/LinkIt) but think it may be overkill so I'm wondering if its possible without a plugin.

**Tags:** redactor, link

> **Comments:**
> **username_1**: Guessing the easiest solution would be to add target="_blank" to all link elements with javascript. But the UX of doing this is awful. There is hardly any cases where target="_blank" is a good idea.  

---

## 3 answers

### Answer by username_2 on 2020-04-16. Score: 2 | Accepted answer

In Craft 3, you can set `"linkNewtab": true` and `"linkTarget": "_blank"` in your redactor config. This should default so the "Open in new tab" is automatically checked when creating links in a redactor field.

<https://imperavi.com/redactor/docs/settings/link/>

> **Comments:**
> **username_3**: (Quibbling, but this of course only affects content in Redactor fields.  It does not result in _all_ external links opening in a new windows - which, again, may or may not be desirable, but the JS solution below is more general, if you do want this...)  

---

### Answer by username_3 on 2016-08-29. Score: 6

Merits of doing this aside, I agree that JS is probably the easiest way to go here.
This code adds target="_blank" to all external links. 
// Make sure any offsite links (non js/mailtos) open in a new window
// from https://css-tricks.com/snippets/jquery/open-external-links-in-new-window/ - comment at end.
function openAllExternalLinksInANewWindow() {
    $(document).on('mousedown', 'a:not([href*="mailto:"],[href*="javascript"])', function(e) {
        var isInternalLink = new RegExp('/' + window.location.host + '/');
        if (!isInternalLink.test(this.href)) {
            $(this).attr('target', '_blank');
        }
    });
}

> **Comments:**
> **username_1**: The only case in which I'd use target="_blank" is if opening a link would destroy some content the user has made on your site. In all other cases it's a very bad practise.  
> **username_0**: Thanks Jeremy. I should've explained better in my question that yes I just wanted to add it just to external links. I'm surprised to see @username_1 opposed to adding target="_blank". Could someone maybe point me to a discussion or study on the pros and cons of using it? Maybe I'm just naive on this one.  
> **username_3**: That's almost a holy war on the web :)  Persoanlly, I don't mind it for external links as we have a large, complex site, and people don't like losing their place on it...but I can also understand others views that it's always bad practise...  I'll edit my answer above to reflect the updated question.  
> **username_1**: @username_0 People like to control for themselves whether a link should open in a new tab. I always hate when a site forces me to open external links in new tabs, just imagine if Google forced you to open all external links in new tabs. It's the same with your site, maybe they're just passing through? https://straightupcraft.com/craft-plugins/ does this when you go to the plugin page and it's always a pain in the ass to have to go back and close the original tab. Also less experienced users and blind users don't notice the new tab, just that they can no longer use the back button  
> **username_0**: Ah ok, I can see both sides now. In my case its longform articles that link to products talked about in the articles. I wanted to open this is a new tab so readers don't lose their place in the article basically but this has made me reconsider. Thanks for the discussion guys!  

---

### Answer by username_4 on 2021-06-01. Score: 0

I've been trying to gather ideas from different places and still not sure how can I do it on Craft 2 having Redactor v2.13 or Redactor II. I looked into the redactor.js file (it's a huge file about 10k lines) and didn't find `linkTarget: '_blank'` to `linkTarget: '_blank'` May be it's because of difference in versions? There are similar mentions though such as

[![Link Target settings Redactor 2.13](https://i.sstatic.net/ilEr0.png)](https://i.sstatic.net/ilEr0.png)

[![linkNewTab settings](https://i.sstatic.net/nLq3D.png)](https://i.sstatic.net/nLq3D.png)

I'd try to explore more and see how this goes. Just incase if someone has already gone through this.


---

