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: 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
- Home page crawledGooglebot fetches and renders the page
- Link is an onclick divNo href for the crawler to read
- Service page not discoveredNo internal link points to it
- 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.
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
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.
Search the code for onclick navigation
In your theme or source code, search for
location.href,window.location,window.openandrouter.pushinside onclick attributes or click listeners on non-<a> elements.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.
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
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
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.
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.
Edit the theme code
Go to Online Store > Themes > Edit code. Search for
onclickandlocation.hrefin sections and snippets. Replace with<a href="{{ product.url }}">or the matching Liquid URL object such ascollection.url.Check apps
If an app injects the clickable element, check its settings for a real link option or ask its support.
Do not use GTM to fake navigation
If a Custom HTML tag adds click handlers that send people to URLs, move the destination into real <a href> links in the page. Keep GTM for tracking only.
Use Link Block or Button elements with a URL
Select the element, open Element Settings and set the Link to a page, URL or section. Avoid custom code that attaches location changes to a Div Block. Wrap clickable cards in a Link Block.
Set the URL in the element's link settings
In the funnel or website builder, select the button, image or text and set its Link to URL or page. Avoid custom JavaScript that changes window.location for navigation you want crawled.
Use the Link option in the editor
Select the element, click the link icon, and choose a page or web address. Where you use Velo code with
wixLocation.to()for navigation, add a normal link as well for any page you want found.
Use button and link fields
Set the URL in the button block, image link or text link settings. Remove code injection that turns elements into scripted links.
Replace onclick navigation with anchors
Change the element to
<a href="/path">. Style it with CSS to look like a card or button.Single-page apps
Use your router's link component (for example
<Link to>or<RouterLink>), which renders a real <a href>. Do not callrouter.pushfrom a click handler on a div for navigation links.
<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
- 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
- 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.
Related issues
- SEO-022Hash-bang or fragment-based URLs (#!) for content pagesFix guide
- SEO-023Pagination links missing so deep pages are never crawledFix guide
- SEO-024Crawl budget wasted on redirecting or 404 URLs in internal linksFix guide
- SEO-017Crawl traps: infinite calendars, session IDs, endless parameter combinationsFix guide
- SEO-003robots.txt blocks CSS or JS needed to render pagesFix guide
- SEO-001robots.txt Disallow: / left over from staging blocks the whole siteFix guide