Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi
i recently moved to shopify and while making my website i made a lot of internal links. however i have since launched on shopify and moved my original domain over, therfore all the links were still showing as shopify domain links, although they were working due to the redirect, i decided to edit each one to the main domain. however this has now left unwanted code of the old link in my html. see below:
how cn i remove this unwanted code for over 500 links, or will i have to manually go to each page and remove it one by one. this is showing as a error on my semrush audit for over 500 links
Solved! Go to the solution
This is an accepted solution.
Hey Ihs
@ihs1 wrote:thank you for this. so will this mean this will be completely removed?? there will be nothing left right?
Yes, it means that those anchor links with the old Shopify URL and without anchor text inside of them will be removed.
@ihs1 wrote:As i am not sure about this can you confirm that the link will still work but with the new primary domain url.
Yes, the links (primary domain links) will still work even though the old Shopify URLs will be removed.
@ihs1 wrote:sorry i dont quite understand the coding side
No worries man, I can help.
This is an accepted solution.
HI Paul
thats great thank you for confirming. Ive just moved to shopify from woocommerce and i am no website or code expert, just a person trying to improve my website and try and increase sales. Im really liking this community and all the help i can get from it
do i need to do anything or give you access to do this please
Much appreciated
Hi @ihs1 ,
There is a faster way to remove unwanted code. You'll need to install a code editor - Visual Studio Code or VSCode is an example. Create a new file and paste your code in. Then using the Search and Replace feature of the code editor, you can search for the code you want to remove and replace that with "" (blank).
Here's a sample:
Using VSCode, I made a new file and copied your code from the screenshot above.
Then using Search and Replace (CTRL + H)
Then, make sure this is turned on:
Then paste this pattern (code below) I made for you, just like the screenshot below:
<a\b[^>]*\bhref="https:\/\/790027-6a\.myshopify\.com\/[^"]*"[^>]*>.*?<\/a>
The pattern above will target <a> tags with a specified href starting URL, and it will allow for any content inside the anchor tags, including other HTML elements and text. That should highlight the stuff I assume you are looking to remove, which should be in this pattern:
<a(anything here)href="https://790027-6a.myshopify.com/(anything here)"(anything here)>(anything here)</a>
Then by clicking this button here, this will replace all the highlighted code with ""(blank).
Or if you prefer replacing it one by one, you can click the button at the right of "AB".
End result after clicking the button should be this:
Hope this helps!
Just a note, make sure to back up your original files inside your computer before attempting to replace anything using the pattern I made. Then if you'd like me to do this for you all for free, just let me know. And if you have any questions at all, feel free to ask.
HI Paul
thank you for this. so will this mean this will be completely removed?? there will be nothing left right?
sorry i dont quite understand the coding side
All i know is that i changed the url of the original link to the primary domain and this shopify url remained in the code and comes up as a error on my semrush audit saying 505 links have no anchor text. however as i mentioned these links were removed from the front end, but looks like they remained in the code
so i assume what you are saying is that this empty link code will be removed
if possible can you help with this as you mentioned
As i am not sure about this can you confirm that the link will still work but with the new primary domain url.
if you can confirm please as i dont want to have any issues adding 505 links again
This is an accepted solution.
Hey Ihs
@ihs1 wrote:thank you for this. so will this mean this will be completely removed?? there will be nothing left right?
Yes, it means that those anchor links with the old Shopify URL and without anchor text inside of them will be removed.
@ihs1 wrote:As i am not sure about this can you confirm that the link will still work but with the new primary domain url.
Yes, the links (primary domain links) will still work even though the old Shopify URLs will be removed.
@ihs1 wrote:sorry i dont quite understand the coding side
No worries man, I can help.
This is an accepted solution.
HI Paul
thats great thank you for confirming. Ive just moved to shopify from woocommerce and i am no website or code expert, just a person trying to improve my website and try and increase sales. Im really liking this community and all the help i can get from it
do i need to do anything or give you access to do this please
Much appreciated
absolutely brilliant
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024