Skip to content

A link a crawler cannot follow

links-not-crawlablemoderate
On this page

Why it matters

  • Google's JavaScript SEO guide is explicit: Google can only discover links that are <a> elements with an href attribute. A click handler, a data-href or a javascript: address works for a visitor and is not a link to a crawler.
  • When the menu or the pagination is built this way, the pages behind it get no link from this page. They may be found late, through other links or the sitemap, or not at all.
  • Screen readers and keyboards meet the same problem: an element without href is not a link to them unless the page adds a role and a tabindex.

Example

Wrong
<a onclick="location.href = '/ar/oud/'">العود</a>
Right
<a href="/ar/oud/">العود</a>

How to fix

Give every link an <a> with a real address, and keep any script on top of it:

html
<a href="/ar/oud/">العود</a>
  • In a single-page app, render <a href> and let the router intercept the click; Next.js Link, Vue's RouterLink and Angular's routerLink do this.
  • An Arabic address is fine as it is, written in Arabic or percent-encoded: what matters is that it is in href.
  • A button that opens a menu or adds to the cart is not a link: make it a <button>.

How we detect

  1. We read the HTML as the server sends it.
  2. We report an <a> without href that a script makes work (onclick, data-href, data-url, data-link, or a framework's click binding), and one in <nav>, role="navigation" or a pagination block; an element with role="link" and no href; and a javascript: href that names a place to go (a location, a path, window.open).
  3. javascript:void(0) and other calls with no address, <a name> anchors, <a> without href or script outside a menu, and links whose href a framework writes (routerLink, ng-href, :href) are not reported.

Links a script adds after the page loads are not read here.