Hi everyone, I’ve been trying to follow along with the ideas above. But I’m still having some trouble. I’m mainly wondering about links within blog posts. I’ve been using bookmarks and external links… with this script work for those too?
If you’re looking for a simple target="_blank" functionality, I’ve been using it for quite a while now.
What below codes does, is check the hostname you’re linking to, compare it to the hostname of your blog. If they don’t match it adds target="_blank" to that link. Links within your domain are left alone.
$(function() {
// add target="_blank" to all non-internal text links
$('.post-full-content a').filter(function() {
return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');
});
It’s a slightly different approach from the accepted answer, but I hope that helps someone.
I am new to Ghost and was wondering why the heck “open in new tab” wasn’t an option with external link. I completely agree with another user that is proper UX.
Thank you so much for this fix. I tested it on my site and worked well.
How is this not the default yet? Anyone with a newsletter who is trying to share info on their post, likely wants to keep their readers on their page, and allow readers to open up extra info on other tabs. This is frankly obnoxious that it hasn’t been implemented or requires extra workarounds.
Try googling the problem and seeing how many people have the same issue. This is also the 17th most viewed post on the forum. Let’s fix this for all customers/users…