Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Links only in JavaScript onclick, not crawlable <a href>: fix

SEO-021Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Search engines discover pages by following links. Google's documentation says it can only reliably follow links that are <a> elements with an href attribute holding a real URL. A link built from a <div>, <span> or <button> with an onclick handler, or an <a> with no usable href, is not a link to a crawler. It is a script that runs when a person clicks.

Not crawlable vs crawlablehtml
<!-- Not crawlable: no href, navigation happens in JavaScript -->
<div class="card" onclick="window.location.href='/pricing'">See pricing</div>
<a href="#" onclick="goTo('/pricing'); return false;">See pricing</a>
<a href="javascript:void(0)" onclick="goTo('/pricing')">See pricing</a>

<!-- Crawlable: real URL in href -->
<a href="/pricing">See pricing</a>

Why it costs you leads or sales

How an onclick-only link hides a page
  1. Home page crawledGooglebot fetches and renders the page
  2. Link is an onclick divNo href for the crawler to read
  3. Service page not discoveredNo internal link points to it
  4. No ranking or AI citationNo organic visits or leads from that page

The crawler never finds the URL, so everything after the link is lost from search.

Pages discovered through linksExample numbers
Pages discovered through links (example)Pages with real <a href> links: 20 pages; Pages reachable only via onclick: 30 pages012232030Pages with real <a hr…Pages reachable only …pages

Example: a site with 50 service pages where the menu uses onclick handlers for 30 of them. Numbers are illustrative.

How to check if your site has it

Find onclick-only links
  1. Compare view-source with the rendered DOM

    Open a key page, press Ctrl+U (Cmd+Option+U on Mac) for the raw HTML, and search for the page you expect to be linked. Then right-click the element in the browser, choose Inspect, and see whether it is an <a> with an href.

  2. Search the code for onclick navigation

    In your theme or source code, search for location.href, window.location, window.open and router.push inside onclick attributes or click listeners on non-<a> elements.

  3. Crawl the site with a crawler tool

    Run a crawler such as Screaming Frog (with JavaScript rendering on) and check the list of pages. Pages that show no inlinks, or only appear via the sitemap, are candidates.

  4. Use Google Search Console's URL Inspection

    Inspect a page, choose View crawled page, and look at the rendered HTML. Check that the links you expect are present as <a href>. Also check Pages > Discovered or Crawled, currently not indexed for pages that depend on those links.

How to fix it

Card that navigates with JavaScript

Before

  • <div onclick="location.href='/pricing'">
  • No URL in the HTML for crawlers
  • Cannot open in a new tab
  • Not announced as a link to screen readers

After

  • <a href="/pricing">
  • URL visible to Google and AI crawlers
  • Works with middle-click and copy link
  • Recognised as a link by assistive tech
Fix by platform
  1. Use the link field of the block or widget

    In the block editor, select the button, card or image and set its URL with the link icon. In page builders (Elementor, Divi, Beaver Builder), use the Link setting rather than a custom onclick or JavaScript action.

  2. Fix theme templates

    If your theme prints onclick navigation, edit the template (use a child theme) and output <a href="<?php echo esc_url( $url ); ?>"> instead.

Clickable card that is still a real linkhtml
<a class="card" href="/pricing" data-track="pricing-card">
  <h3>Pricing</h3>
  <p>Compare plans</p>
</a>

<style>
  .card { display: block; text-decoration: none; color: inherit; }
</style>

How to confirm it's fixed

Confirmation checks
  • View source or Inspect shows an <a> with a real href for each link
  • The href is a real URL, not #, javascript:void(0) or empty
  • Middle-click opens the destination in a new tab
  • A crawler with JavaScript rendering lists the target pages with inlinks
  • Search Console URL Inspection shows the link in the rendered HTML
  • Previously hidden pages move to indexed over the following weeks

How to prevent it happening again

Prevention habits
  • Add a rule to your build or code review: navigation must use <a href>
  • Use your framework's link component instead of router calls in click handlers
  • Include every important page in your XML sitemap as a backup
  • Run a rendered crawl after every theme, menu or redesign change
  • Test key pages with JavaScript disabled to see what links remain

How FunnelGuard handles this

Frequently asked questions

Questions people ask

Does Google follow onclick links?

Not reliably. Google follows <a> elements with an href attribute. It does not click elements, so a URL that only appears inside an onclick handler may never be found. Use a real link.

Why are some of my pages not being indexed even though they are on my site?

One common cause is that no crawlable link points to them. If your menu, cards or buttons navigate through JavaScript onclick handlers instead of <a href>, Google may not discover those pages. Check for inlinks with a rendered crawl.

Is <a href="#" onclick="..."> crawlable?

No. The href of # points back to the same page, so a crawler sees no destination. The real URL must be in the href attribute. Use <a href="/page"> and keep any script as an extra.

How do I make a div clickable and still SEO friendly?

Wrap the content in an <a href="/url"> and style it with display: block, or put an anchor inside the card. This keeps the whole area clickable while giving crawlers a real URL.

Does a sitemap fix onclick-only links?

A sitemap helps Google find the URLs, but it is not a replacement for links. Internal links also show which pages matter and pass signals. Use both.

Do JavaScript frameworks like React or Vue have this problem?

Only if navigation is coded with click handlers on non-link elements. Framework link components such as React Router's Link or Vue Router's RouterLink render real <a href> tags, which are crawlable.

How do I check whether Google sees my links?

In Search Console, use URL Inspection, then View crawled page and check the rendered HTML for the <a href> elements. A JavaScript-rendering crawler gives you the same view across the whole site.

Does FunnelGuard detect onclick-only links?

No. FunnelGuard does not check this yet. It runs customer journeys such as forms and checkouts, so use a rendered crawl and Search Console to watch for crawlable link problems.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.