具有 JavaScript 功能的 SEO 和 <a href="#">...</a> 标签
SEO and <a href="#">...</a> tags with JavaScript functionality
自从过去几周我们深入研究 SEO 指南以来,我们遇到了一个问题,但我们没有找到令人满意的答案。 (我们根本不同意这个话题)。我们希望对此有更多意见。
由于最近许多项目使用 jQuery 和 Bootstrap,所以锚标记经常被使用
<a href="#" class="btn btn-add-to-cart" data-item="65464823">Add to cart</a>
然后一些花哨的 JavaScript 代码将在元素上附加一个事件处理程序,这样当有人单击此 link.
时,产品将被添加到购物车
由于 SE 蜘蛛会跟随所有 links,它们最终会跟随所有这些内部 links(注意 #),这对排名不利。
我们中的一些人认为将 rel="nofollow"
属性添加到此类 link 以防止蜘蛛跟踪这些 link 是个好主意。其他人说这会阻止当前页面(由 # 定位)被正确索引。
将所有这些 'placeholder <a>
-tags' 替换为 <span>
或 <button>
可能是一个想法,但(使用 Bootstrap)有时它们存在于真实links,并且由于某些元素的浏览器渲染问题,将会出现细微的差异。 (尤其是在使用 btn-group 时)
在 Bootstrap 手册中我们发现:
"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"
.
但是 SE 蜘蛛会考虑这个 role
属性吗?
我们一如既往地好奇其他开发人员如何解决这个问题。
我们已经看过这些(和其他)文章
http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
Href attribute for JavaScript links: “#” or “javascript:void(0)”?
如果元素充当按钮而不是锚 link,则不应将它们编入索引。应该使用 rel="nofollow"
。更好的是它应该是一个按钮,而不是一个锚 link。
空锚点 link 除了“#”之外什么都没有,这不仅对 SEO 不利。
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 能够执行一些 Javascript。因此,如果点击指向另一个页面,机器人很可能会尝试跟随它。
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.
没有。如果机器人设法分析这些链接,则意味着他们必须首先访问具有这些链接的页面的 URL。因此,他们对该页面进行索引就足够了。
But will SE spiders take this role attribute in account?
我不会依赖这个。如果您担心或想安全应对机器人,您可以随时在这些链接上设置 NOFOLLOW。
自从过去几周我们深入研究 SEO 指南以来,我们遇到了一个问题,但我们没有找到令人满意的答案。 (我们根本不同意这个话题)。我们希望对此有更多意见。
由于最近许多项目使用 jQuery 和 Bootstrap,所以锚标记经常被使用
<a href="#" class="btn btn-add-to-cart" data-item="65464823">Add to cart</a>
然后一些花哨的 JavaScript 代码将在元素上附加一个事件处理程序,这样当有人单击此 link.
时,产品将被添加到购物车由于 SE 蜘蛛会跟随所有 links,它们最终会跟随所有这些内部 links(注意 #),这对排名不利。
我们中的一些人认为将 rel="nofollow"
属性添加到此类 link 以防止蜘蛛跟踪这些 link 是个好主意。其他人说这会阻止当前页面(由 # 定位)被正确索引。
将所有这些 'placeholder <a>
-tags' 替换为 <span>
或 <button>
可能是一个想法,但(使用 Bootstrap)有时它们存在于真实links,并且由于某些元素的浏览器渲染问题,将会出现细微的差异。 (尤其是在使用 btn-group 时)
在 Bootstrap 手册中我们发现:
"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 appropriaterole="button"
.
但是 SE 蜘蛛会考虑这个 role
属性吗?
我们一如既往地好奇其他开发人员如何解决这个问题。
我们已经看过这些(和其他)文章
http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
Href attribute for JavaScript links: “#” or “javascript:void(0)”?
如果元素充当按钮而不是锚 link,则不应将它们编入索引。应该使用 rel="nofollow"
。更好的是它应该是一个按钮,而不是一个锚 link。
空锚点 link 除了“#”之外什么都没有,这不仅对 SEO 不利。
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 能够执行一些 Javascript。因此,如果点击指向另一个页面,机器人很可能会尝试跟随它。
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.
没有。如果机器人设法分析这些链接,则意味着他们必须首先访问具有这些链接的页面的 URL。因此,他们对该页面进行索引就足够了。
But will SE spiders take this role attribute in account?
我不会依赖这个。如果您担心或想安全应对机器人,您可以随时在这些链接上设置 NOFOLLOW。