How do I make external links open in a new browser tab?

Take note that according to most usability experts, opening links in a new browser tab is considered bad practice.

We invite you to read the article Seven tricks that Web users don't know, particularly the section Second browser windows: “Avoid spawning multiple browser windows if at all possible — taking the "Back" button away from users can make their experience so painful that it usually far outweighs whatever benefit you're trying to provide. One common theory in favor of spawning the second window is that it keeps users from leaving your site, but ironically it may have just the opposite effect by preventing them from returning when they want to.”

If you would still like to open external links in a new window, follow these instructions:

1. Go to the Edit HTML/CSS page.

2. Under the Layouts folder, click on theme.liquid to open it in the online code editor.

3. Scroll through the code and locate the closing body tag.

4. Paste the following code above the closing body tag:

jQuery('a[href^="http"]').not('a[href^="{{ shop.url }}"]').attr('target', '_blank');

5. Save your changes.

Ready to put what you've learned into action?

Build an online store with Shopify. Try it free.

Experience the future of retail now.

Shopify Point of Sale. Try it free.