Hey @MasterShake1441 , were you able to solve the problem yet?
Topic summary
A Shopify user sought to make a single header navigation link open in a new tab, finding existing guides unhelpful or outdated. They were using the Refresh theme with minimal coding experience.
Initial Attempts:
- Adding
target="_blank"to<a>tags inheader.liquidcaused all navigation links to open in new tabs, not just the desired one. - The specific link code wasn’t easily identifiable in the theme files.
Working Solution:
The original poster resolved the issue by adding JavaScript code to global.js that automatically opens all external links in new tabs:
const links = document.links;
for (let i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname !== window.location.hostname) {
links[i].target = '_blank';
links[i].rel = 'noreferrer noopener';
}
}
While not targeting a single specific link as originally intended, this approach achieves the functional goal by detecting external URLs. Multiple users confirmed this solution worked for them through early 2025. A WordPress alternative using PHP filters was also shared for reference.