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. From your shop admin, go to the Themes page.

  2. Hover over the button and click Edit HTML/CSS.

    #

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

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

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

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

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.