Some of my internal website links have suddenly started opening in new tabs, but didn’t used to.
I want all of my internal links to stay on the same tab and not open new ones. I can’t figure out why its doing this all of a sudden, and only for a select few links.
One of the links is my logo on the home page which I have added coding to, so that it opens my collection page. I have now even gone back and added the target=‘_self’ coding but still it opens in a new tab:
Another link is some text within my returns policy which I have added a hyperlink to, and have selected the “open this link in : the same window” option. But still its opening in a new tab.

My website is Stephanosyung.com, If anybody could help that would be much appreciated.
Thank you.
Well, regarding to your menu logo link, through inspection it has target = “_blank”, which will open in a new page for sure. You need to change that.
What theme you’re using?
Hi, upon inspection you’re right, I can see target=“_blank” appear in a number of places for the logo link through chrome developer tools.
However, I’ve tried checking all of my code files but can’t seem to find that piece of coding anywhere. Ive searched header.liquid, theme.liquid, logo-bar.liquid, site-nav.liquid and can’t see anything.
Im using the Flow theme.
Well, it have to be either on these files you mentioned or around your theme, section or block settings.
Try contacting your theme developers.
I have found that when I remove the piece of coding that makes my external links open in new tabs it also stops the couple internal links I am referring to from opening in new tabs.
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’;
links[i].rel = ‘noreferrer noopener’;
}
}
Why would it be that this coding is recognising those links (the logo link, and the hyperlink on my returns policy) as external links when they are in fact internal and use my website URL
Well, as per the code you attached it checks if the link is within the same website hostname or not. And depending on that either open the link using a new tab or not.
The answer for your question it totally in hands of your theme development team i guess.
Hope you solved your issue at the end.