Shopify to Open External Links In a New Tab

In Shopify there is no built in setting to enable opening links in a new tab. However it can be achieved by using a piece of JavaScript.

The below code will enable all external links to open in a new tab site-wide. All you have to do is to copy and paste this piece of code into your custom.js 

If custom.js is not available then you can try placing the code into theme.js


var links = document.links;
for (let i = 0, linksLength = links.length ; i < linksLength ; i++) {
if (links[i].hostname !== window.location.hostname) {
links[i].target = '_blank';


Save and test. All set.

Leave a comment

Please note, comments must be approved before they are published