What's your biggest current challenge? Have your say in Community Polls along the right column.

remove unwanted link with no anchor text

Solved

remove unwanted link with no anchor text

ihs1
Explorer
106 1 11

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:

 

Screenshot 2024-08-19 015428.png

 

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

Accepted Solutions (2)
PaulMartin
Shopify Partner
623 60 146

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.

contact@paulmartinlopez.com
Feel free to email me! 😄
I'm open to conversations or work ʕ •ᴥ•ʔ

View solution in original post

ihs1
Explorer
106 1 11

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

View solution in original post

Replies 5 (5)

PaulMartin
Shopify Partner
623 60 146

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.

PaulMartin_0-1724047900813.png

Then using Search and Replace (CTRL + H) 

PaulMartin_1-1724047974896.png
Then, make sure this is turned on:

PaulMartin_2-1724048044913.png

Then paste this pattern (code below) I made for you, just like the screenshot below:

 

 

 

 

<a\b[^>]*\bhref="https:\/\/790027-6a\.myshopify\.com\/[^"]*"[^>]*>.*?<\/a>

 

 

 

 

PaulMartin_3-1724048119106.png

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).

PaulMartin_4-1724048699122.png

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:

PaulMartin_5-1724048883487.png


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.

contact@paulmartinlopez.com
Feel free to email me! 😄
I'm open to conversations or work ʕ •ᴥ•ʔ
ihs1
Explorer
106 1 11

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

PaulMartin
Shopify Partner
623 60 146

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.

contact@paulmartinlopez.com
Feel free to email me! 😄
I'm open to conversations or work ʕ •ᴥ•ʔ
ihs1
Explorer
106 1 11

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

ihs1
Explorer
106 1 11

absolutely brilliant