Works perfectly on my blog. Thanks @Aileen
1 Like
Could we have this as a feature please?
3 Likes
I just wanted to say thanks and 2 things:
- 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.
- 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?
3 Likes
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.
2 Likes
Thanks, bro it works
1 Like
I got this working with the script of @FallingPanda
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
<script>
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');
}
}
</script>
Works!!! thank you!!!