skip to Main Content

Since we are diving into SEO guidelines the past weeks we came across a question for which we didn’t find a satisfying answer. (We simply didn’t agree on this topic). We would like more opinions on this.

Since many projects use jQuery and Bootstrap lately, anchor tags often get used like

<a href="#" class="btn btn-add-to-cart" data-item="65464823">Add to cart</a>

Then some fancy JavaScript code wil attach an event handler on the element so the product will be added to the cart when someone clicks this link.

As SE spiders follow all links they would end up following all these internal links (note the #) which can’t be good for the ranking.

Some of us thought it would be a good idea to add the rel="nofollow" attribute to these kind of links to prevent spiders from following these links. Others said this would prevent the current page (targeted by the #) to be indexed properly.

It could be an idea to replace all these ‘placeholder <a>-tags’ with <span>‘s or <button>‘s but (using Bootstrap) sometimes they exist next to real links and a small difference will be visible due to browser rendering issues with some elements. (especially when using btn-group)

In the Bootstrap manual we found:

“If the <a> elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button".

But will SE spiders take this role attribute in account?

We are, as always, curious about how other developers tackle this issue.


We’ve seen these (and others) articles already

http://en.wikipedia.org/wiki/Unobtrusive_JavaScript

Href attribute for JavaScript links: “#” or “javascript:void(0)”?

2

Answers


  1. If the elements are acting as buttons and not as anchor links they should not be indexed. The rel="nofollow" should be used. Better yet it should be a button, not an anchor link.

    Having an empty anchor link with nothing but a ‘#’ is bad practice not only for SEO.

    Login or Signup to reply.
  2. Then some fancy JavaScript code wil attach an event handler on the element so the product will be added to the cart when someone clicks this link.

    Google is capable of executing some Javascript. Hence, if the click leads to another page, it likely bots will try to follow it.

    As SE spiders follow all links they would end up following all these internal links (note the #) which can’t be good for the ranking.

    The # will be ignored. No harm done to your ranking. Crawling and ranking a separate things.

    Some of us thought it would be a good idea to add the rel=”nofollow” attribute to these kind of links to prevent spiders from following these links.

    It is not a bad idea, especially if you have a large site. You don’t want bots to lose their time unnecessarily on those links. But, it is not an absolute must.

    Others said this would prevent the current page (targeted by the #) to be indexed properly.

    No. If bots managed to get to analyze these links, it means they must have had access to the URL of the page having those links in the first place. Hence, it is enough for them to index that page.

    But will SE spiders take this role attribute in account?

    I would not rely on this. If you are worried or wanna play it safe regarding bots, you can always set NOFOLLOW on those links.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search