How to add no follow to specific links with Javascript?

kurosaki4d

Power Member
Joined
Apr 24, 2018
Messages
689
Reaction score
82
Hello,

I have some cloaking affiliate links in pages to which I would like to add the attributes of nofollow.

However, I'm looking for a way in coding that will allow me to target links that contain specific string, like /go/pluto

I was hoping someone might provide me with something that may do the job for me.



Thank you so much in advance!
 
Do you want this in real-time? Meaning a javascript loaded in the same html, which will wait for the page to load then add "no-follow" to your links? Or do you just want a bot to modify your links for you locally so you can then upload them to your website?

The problem with the 1st method is that crawlers might not wait or support javascript. So even if you add a "load" event that will work on every browser, it might not work as intended for crawlers, and the links would still be ******** when google / other indexers check them.
 
Do you want this in real-time? Meaning a javascript loaded in the same html, which will wait for the page to load then add "no-follow" to your links? Or do you just want a bot to modify your links for you locally so you can then upload them to your website?

The problem with the 1st method is that crawlers might not wait or support javascript. So even if you add a "load" event that will work on every browser, it might not work as intended for crawlers, and the links would still be ******** when google / other indexers check them.

Thank you man for your answer !

Wow that's what i was afraid of, that the google bots might miss it !

I added so many links in my website that i forgot to add the nofollow, it's just to much work to have to go through each one, and i want that even for future links, so i was hoping for an automated way !

Hmmm, so you recommend a php method instead of javascript ? or is there another way ?
 
what ever way it done will take time as it needs to be crawled to be active .

unless can be forced to be crawled , like altered then link pinged or re indexed with a indexer .

maybe ?

i dont no if it possible to get a URL re-indexed updated after it altered , that your real problem ,

this servise suppose to be the quickest indexer
https://speed-links.net
 
Last edited by a moderator:
Yes, you can make all links no-follow with php (or making only external links no-follow and keeping internal links do-follow as well)...

Doing it with a JS script is no-no as many crawlers don't load JS.
 
Yes, you can make all links no-follow with php (or making only external links no-follow and keeping internal links do-follow as well)...

Doing it with a JS script is no-no as many crawlers don't load JS.

you are right ! this sould be done in the backend before the html render !
 
Yes, you can make all links no-follow with php (or making only external links no-follow and keeping internal links do-follow as well)...

Doing it with a JS script is no-no as many crawlers don't load JS.

Thank you for your advice.

I have this function in php that replaces and adds no follow to all the external links, but that happens after the content of the page in php is loaded. Do you think that works ?
 
Yes, as said above, it needs to be done in PHP (or whatever server you're using). The a elements need to be sent to the browser with all their attributes to make sure they get picked up by google. (Google can execute and index JavaScript-generated content but it's still unreliable to this day).
 
Back
Top