Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Links without href: how to fix JS links Google can't crawl

SEO-141Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A crawlable link is an <a> element with an href attribute holding a URL that a crawler can request. Many sites build navigation another way. A <div onclick="go('/pricing')">, a <span> with a click listener, a <button> that calls window.location, or an <a> with no href all work for a human with a mouse. Google's documentation says it only reliably follows <a> elements with an href. It does not click things or run your event handlers to find links.

Not crawlable vs crawlablehtml
<!-- Not crawlable -->
<div onclick="location.href='/pricing'">Pricing</div>
<a onclick="go('/pricing')">Pricing</a>
<a href="javascript:void(0)" onclick="go('/pricing')">Pricing</a>
<button onclick="location.href='/pricing'">Pricing</button>

<!-- Crawlable -->
<a href="/pricing">Pricing</a>

Why it costs you leads or sales

If the only route to a page is a link without an href, Google may never discover it. Pages that are not found do not rank, so they bring no search or AI-search traffic. Even pages found another way, such as through a sitemap, get weaker signals because internal links pass context through their anchor text and help show which pages matter.

How a missing href loses pages
  1. Crawler fetches category pagePage is found and rendered
  2. Product cards use onclickNo href to follow
  3. Product pages not discoveredNever queued for crawling
  4. No organic visits to productsNo rankings, no leads

The crawler reaches the listing page but cannot follow the click-only cards.

Product pages discovered by crawlersExample numbers
Product pages discovered by crawlers (example)Click-only cards: 12 pages; Real a href links: 200 pages07715312200Click-only cardsReal a href linkspages

Example: a 200-product catalogue where cards are click-only versus real links. Numbers are illustrative.

How to check if your site has it

Find links crawlers can't follow
  1. View the rendered links in DevTools

    Right-click a menu item or card, choose Inspect, and look at the element. If it is not an <a> with an href, it is not a crawlable link.

  2. Search the page for anchors with no href

    In the DevTools console run document.querySelectorAll('a:not([href]), a[href="#"], a[href^="javascript:"]') and review the list.

  3. Compare with a crawl

    Crawl the site with a crawler such as Screaming Frog with JavaScript rendering on, and check whether pages you expect are missing or have very few internal links pointing to them.

  4. Use Google Search Console

    Run URL Inspection on a key page and open the rendered HTML. Then check the Pages report for 'Discovered' or 'Crawled' pages that should be indexed, and for pages with no internal links.

  5. Turn off JavaScript

    Disable JavaScript in your browser and click around. Links that stop working are likely missing a real href.

Console snippet: list suspect linksjavascript
const bad = document.querySelectorAll(
  'a:not([href]), a[href="#"], a[href^="javascript:"]'
);
console.log(bad.length + ' suspect links');
bad.forEach(el => console.log(el.outerHTML.slice(0, 120)));

// Click-only elements often carry an onclick attribute
document.querySelectorAll('[onclick]:not(a)').forEach(el =>
  console.log(el.tagName, el.textContent.trim().slice(0, 40))
);

How to fix it

Turn click handlers into real links
  1. Use an <a> element for anything that goes to a URL

    If a click takes the visitor to another page, it should be <a href="/the-url">. Use <button> only for actions that do not change the URL, such as opening a menu.

  2. Use a real, absolute-path or full URL

    Avoid href="#" and javascript: values. The href should be the address a visitor could paste into a new tab.

  3. Keep JavaScript as an enhancement

    If your app handles the click without a full reload, let the handler call preventDefault and update the view, while the href stays in place for crawlers and for open-in-new-tab.

  4. Style the link instead of replacing it

    Wrap cards in an <a> or put a link on the title, and use CSS to make it look the way you want.

  5. Re-crawl and re-test

    Run your crawler again and confirm the formerly hidden pages now appear with internal links.

Fix by platform
  1. Replace the handler with an anchor

    Change <div onclick="go('/pricing')"> to <a href="/pricing">. If you need a script, intercept the click on the anchor and call event.preventDefault().

  2. Use your router's link component

    In React Router use <Link to="/pricing">, in Next.js use <Link href="/pricing">, in Vue Router use <RouterLink to="/pricing">. They render a real <a href>. Do not call navigate() or router.push() from a div click for ordinary navigation.

Progressive enhancement examplehtml
<a href="/pricing" class="nav-link" data-spa>Pricing</a>

<script>
document.querySelectorAll('a[data-spa]').forEach(function (a) {
  a.addEventListener('click', function (e) {
    if (e.metaKey || e.ctrlKey || e.shiftKey) return; // keep open-in-new-tab
    e.preventDefault();
    loadView(a.getAttribute('href')); // your own view loader
    history.pushState({}, '', a.getAttribute('href'));
  });
});
</script>

How to confirm it's fixed

Confirmation checks
  • The console snippet returns 0 suspect links on key templates
  • Every menu, card and pagination item is an <a> with a real href in Inspect
  • Middle-click or right-click > Open in new tab works on those items
  • A JavaScript-rendering crawl finds the previously missing pages
  • Search Console URL Inspection shows the links in the rendered HTML
  • Newly linked pages start appearing as discovered in the Pages report

How to prevent it happening again

Habits that keep links crawlable
  • Add a rule to your code review: navigation uses <a href>, actions use <button>
  • Use the framework's link component, not manual navigation calls, for page links
  • Run a rendered crawl after each redesign or theme change
  • Disable JavaScript and click through key paths before launches
  • Keep an XML sitemap as a backup discovery route, not as a replacement for links
  • Ask agencies and plugin vendors how their widgets output links

How FunnelGuard handles this

FunnelGuard does not check for links without an href today. It is a possible future check. Nothing in FunnelGuard will tell you that a menu or product card is click-only.

What FunnelGuard does cover nearby is the journeys that matter to revenue. A robot visitor runs your lead forms, checkouts, booking and chat buttons on a schedule, checks each step and the tracking hits, and sends one alert with a screenshot if a step fails. That tells you if a click path breaks for a real browser, but not whether search engines can crawl your links.

Questions people ask

Does Google follow links without an href?

Not reliably. Google says it follows <a> elements with an href attribute. An anchor with no href, or a div or button with a click handler, gives the crawler no URL, so the target page may never be discovered through that link.

Why are my JavaScript links not being crawled?

They are probably built with onclick handlers, divs, buttons, or anchors with href="#" or javascript:void(0). Googlebot does not click elements to see where they lead. Switch them to <a href="/real-url"> so the URL is in the HTML.

Is href="javascript:void(0)" bad for SEO?

Yes, when it is used for navigation. It gives crawlers no destination URL. Use a real href, and let your script call preventDefault if you want to handle the click without a page load.

How do I make JavaScript links crawlable?

Output a real <a> element with an href pointing to the target URL. In frameworks, use the router's link component, such as Link in React Router or Next.js. Keep any script as an enhancement on top of the real link.

Do React or Next.js Link components create crawlable links?

Yes. They render a normal <a href> in the page. The problem comes when developers use router.push or navigate inside a div or button click instead of the link component for normal page links.

How can I find anchors without href on my site?

Run document.querySelectorAll('a:not([href]), a[href="#"], a[href^="javascript:"]') in the browser console, and crawl the site with a tool that renders JavaScript. Also look for div or button elements used as links.

Can a sitemap replace proper links?

No. A sitemap can help Google find URLs, but internal links also show structure and importance. Pages found only through a sitemap tend to have weaker signals, so use both.

Does FunnelGuard check for links without href?

No. It is a possible future check. FunnelGuard currently runs your key customer journeys, such as forms and checkouts, and checks steps and tracking, not the crawlability of your links.

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.