3

How would Google behave if encounter with a link having two different rel attribute?

<a href="example.com" rel="follow" rel="nofollow">hello</a>

I'm trying to purge content user insert into DB. I need to prevent user from making links as follow for search engines, but I'm not going to do it for internal links so I can't use meta in header to prevent all links from following. So if a user has added rel attribute manually I would have the new link with two rel like above example. I use this method for making my regex.

Community
  • 1
  • 1
alex
  • 7,551
  • 13
  • 48
  • 80
  • This situation probably is not defined. Simple reason is that it is obviously impossible to have two attributes with the same name in a single element. Therefore it is up to the implementation how it behaves. – arkascha Oct 06 '16 at 08:04
  • Does Google document anywhere that they would recognize the `follow` link type (which is invalid in HTML5)? – unor Oct 06 '16 at 10:40

1 Answers1

4

You cannot have more than one rel attribute into one element, but you can insert more than one argument into a single rel attribute value - just delimit them with a space:

Valid: <a href="example.com" rel="follow nofollow">hello</a>

Not Valid: <a href="example.com" rel="follow" rel="nofollow">hello</a>

I think for what you are looking for :

GoogleBot does obey the rel="nofollow" attribute.. as for rel="follow" - I don't think so. rel="follow" is only used to override the default "nofollow"

It actually depends on what you want to achieve, If you want "nofollow" then just use rel="nofollow" & the rel="follow" is not needed, But on the other hand if you want rel="follow", then you need to provide rel="nofollow" first and then override it by rel="follow" like below

<a href="example.com" rel="nofollow follow">hello</a>

Here is a good article which explains it

Nikhil Nanjappa
  • 6,454
  • 3
  • 28
  • 44