I want one of my Homepage Navigation Header Links to Open in a New Tab vs. Internal Redirect

Solved
alazee
New Member
4 0 0

I have the Icon theme. I want one of my Homepage Navigation Header Links to Open in a New Tab vs. Internal Redirect to a page on my website. 

Specifically, I want my "Blog" to open a new tab to my "Blog" that's hosted on another domain. 

Thank you!!

0 Likes

Hello,

Please send the URL of your website so we can analyze it and help you out. Thanks!

◦ Product page slider & thumbnails with swiping for free themes: Minimal | Debut | Brooklyn | Supply
◦ Replace apps with simple copy/paste code snippets. Examples clicking here.
0 Likes
alazee
New Member
4 0 0
www.nourzero.com
On the header, BLOG, I want to go to a new URL vs. redirecting within the
same tab. Thanks!
0 Likes
alazee
New Member
4 0 0

www.nourzero.com

On the header, BLOG, I want to go to a new URL vs. redirecting within the same tab. Thanks!
0 Likes

This is an accepted solution.

Hey,

1. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
2. paste this code right above the </body> tag:

<script>
  document.addEventListener("DOMContentLoaded", function() {
Array.from(document.querySelectorAll('#shopify-section-mobile-navigation a, #shopify-section-header a'))
  .filter(el => el.textContent.toLowerCase().trim() === 'blog' )
  .map(e => e.setAttribute('target', '_blank'))
            });

</script>


Let me know if it works!

◦ Product page slider & thumbnails with swiping for free themes: Minimal | Debut | Brooklyn | Supply
◦ Replace apps with simple copy/paste code snippets. Examples clicking here.
alazee
New Member
4 0 0
Amazing, it worked! Thank you!
0 Likes

You're welcome!

Please don't forget to mark my answer as solution and give it a like

◦ Product page slider & thumbnails with swiping for free themes: Minimal | Debut | Brooklyn | Supply
◦ Replace apps with simple copy/paste code snippets. Examples clicking here.
0 Likes
johanochnystrom
New Member
1 0 0

Hey! Would something similar work to open the link "PRESS" in my footer menu in a new tab? It links to a google drive but I don't want to loose my visitors from our page. 

 

url: https://johanochnystrom2021.myshopify.com

0 Likes