I want my external links to open in a new tab

Works perfectly on my blog. Thanks @Aileen

1 Like

Could we have this as a feature please?


I just wanted to say thanks and 2 things:

  1. Thank you for all the people who have contributed here. I have tried and tested many of the above suggestions. However, the previous code snippets listed have an issue on mobile devices, tapping on the hamburger menu opens a blank new tab. So this is not right, only this particular snippet works in that regard.
  2. This really should be addressed platform wide, not in a forum. I really think this should be the default or an option without having Ghost customers having to spend hours or days struggling, researching, testing and trying workarounds that are inaccurate. Even this thread did not help until I found this snippet near the bottom.

Why on earth is the Ghost devs so resistant on implementing this as an option?


So good - thanks for your help.

I wish they would just make this the default or at least tell why not or make it configurable at the link creation time.


Thanks, bro it works :slight_smile:

1 Like

The same applies to Discourse (fantastic piece of software too):

I got this working with the script of @FallingPanda :pray:

Is there any way to make Navigation links to open a new tab though? For example secondary navigation.

This help me a lot, thanks!

If they are external links they will still open in a new window using the code I posted below

  const anchors = document.querySelectorAll('a');
  for (x = 0, l = anchors.length; x < l; x++) {
    const regex = new RegExp('/' + window.location.host + '/');
    if (!regex.test(anchors[x].href)) {
      anchors[x].setAttribute('target', '_blank');
      anchors[x].setAttribute('rel', 'noopener');

Works!!! thank you!!!