What does Google say about SEO? /
Quick SEO Quiz

Test your SEO knowledge in 3 questions

Less than 30 seconds. Find out how much you really know about Google search.

🕒 ~30s 🎯 3 questions 📚 SEO Google

Official statement

Having a link with href and an onclick handler that prevents the default action and updates the current page's content is not considered cloaking, as long as the displayed content meets expectations and is not misleading. Google still considers the element a valid link.
18:32
🎥 Source video

Extracted from a Google Search Central video

⏱ 20:04 💬 EN 📅 23/06/2020 ✂ 7 statements
Watch on YouTube (18:32) →
Other statements from this video 6
  1. 2:02 Faut-il vraiment abandonner les outils tiers pour tester le rendu HTML de vos pages ?
  2. 2:02 Faut-il vraiment éviter les balises meta en double dans le HTML et le JavaScript ?
  3. 4:02 Pourquoi Google ignore-t-il les liens cachés derrière vos menus déroulants ?
  4. 7:56 Faut-il débloquer JavaScript et CSS dans le robots.txt pour le référencement ?
  5. 9:01 Pourquoi Google crawle vos fichiers JS/CSS mais ne les indexe jamais ?
  6. 13:43 Bloquer JavaScript et CSS peut-il vraiment dégrader votre SEO ?
📅
Official statement from (5 years ago)
TL;DR

Google states that a href link accompanied by an onclick handler that prevents the default action and updates the current page's content is not considered cloaking, as long as the displayed content remains consistent with expectations. The element retains its status as a valid link in the eyes of the search engine. This clarification paves the way for modern JavaScript implementations without the risk of penalty, but content consistency remains the determining criterion.

What you need to understand

What does Google really mean by 'consistent content'?

Martin Splitt's statement sets a clear framework: a link with href and onclick that prevents traditional navigation is not cloaking if the displayed content meets user expectations. The determining criterion is not the technical method used, but the consistency between what the link promises and what is then displayed.

Specifically, if your link says 'See customer reviews' and the onclick displays a modal with reviews, that's acceptable. If the same link displays an ad or unrelated content, you cross the red line into cloaking. Google still considers the element a valid link for crawling, even if the JavaScript interaction alters the browser's default behavior.

Why this clarification now?

Modern JavaScript frameworks — React, Vue, Angular — heavily rely on client-side routers that intercept link clicks to avoid a full page reload. This approach enhances user experience and performance, but has long caused doubts among SEOs: Will Google consider these links valid?

Splitt's response clears up this ambiguity. Google does not penalize the use of onclick to enhance user experience, as long as the href remains present and the displayed content stays relevant. This represents an official validation of widely used practices in modern web development.

What distinguishes this approach from traditional cloaking?

Traditional cloaking involves serving different content to bots and users, often to manipulate rankings. Here, the content remains the same for Googlebot and the user — only the display method changes. The href remains accessible for crawling, and onclick only alters the navigation mechanics.

The nuance is critical: Google crawls the href, not the onclick event. If your link points to /page-a in the href, but onclick displays content from /page-b, you create an inconsistency. In this case, you risk being perceived as misleading, even without malicious intent.

  • A link with href + onclick remains a valid link for Googlebot, provided the displayed content matches expectations.
  • The consistency criterion outweighs the technical method: what matters is that the user receives what the link promises.
  • Google crawls the href, not the onclick — any divergence between the two creates a risk of confusion.
  • This clarification validates the practices of modern JavaScript frameworks that rely on client-side routers.
  • The absence of href or an onclick that displays irrelevant content remains problematic and may be interpreted as cloaking.

SEO Expert opinion

Is this statement consistent with observed practices on the ground?

Yes, overall. Sites using modern JavaScript frameworks with client-side routing generally do not suffer cloaking penalties, as long as the content remains accessible and consistent. Field tests show that Googlebot correctly indexes these pages, even with complex JavaScript interactions.

The nuance lies in the quality of the implementation. Sites that only render content accessible via JavaScript, without serving a basic HTML version, are taking a risk. Googlebot can execute JavaScript, but it doesn't always do so exhaustively — especially if the crawl budget is limited or if the JavaScript is poorly structured.

What gray areas remain in this statement?

Splitt refers to 'content that meets expectations', but Google does not precisely define this criterion. What constitutes a legitimate 'expectation'? If a link says 'Learn more' and opens a modal with 50% relevant content and 50% ads, is that acceptable? [To be verified] — this gray area leaves room for interpretation.

Another vague point: how does Google assess the consistency between the href and the content displayed via onclick? If the href points to a complete page and onclick only displays a snippet of that page in a modal, does Google consider that coherent? The statement does not provide a precise technical answer, leaving practitioners in the dark.

In what cases might this rule not apply?

If your onclick loads dynamic content that does not exist in the href, you create a dissonance that Googlebot may interpret as misleading. For example, a link to /product-a that, via onclick, displays the features of /product-b in a modal: technically, the displayed content does not match the crawled href.

Sites that abuse modals to conceal strategic content behind onclick without a valid href remain exposed. Google can crawl the link, but if the displayed content is not accessible via the href, it may not be indexed — or worse, be viewed as an attempt to manipulate. Let's be honest: just because Splitt says it's not cloaking doesn't mean Google will index everything you display via JavaScript.

Attention: Google does not guarantee the indexing of content displayed solely via onclick, even if it is not considered cloaking. The distinction between 'no penalty' and 'guaranteed indexing' is crucial.

Practical impact and recommendations

What should you do concretely to stay compliant?

Keep a valid and relevant href on all your links, even those that trigger JavaScript interactions. The href should point to a real URL that displays the promised content. If your onclick prevents default navigation, ensure the displayed content on the current page corresponds to what the user would have received by following the href.

Test your pages with Googlebot Fetch and Render or tools like Screaming Frog in JavaScript mode to verify that the content is accessible and consistent. If Googlebot crawls the href and onclick displays something else, you risk being perceived as inconsistent — even without malicious intent.

What mistakes should be absolutely avoided?

Never create a link with a blank href, anchored (#), or javascript:void(0) if you are relying solely on onclick to display content. Without a valid href, Google cannot crawl the destination, and you lose any SEO benefit from that link. The 'ghost link' is a classic mistake among JavaScript developers.

Avoid also loading different content via onclick compared to what the href promises. If your link says 'See technical specifications' and onclick displays a promotional video, you create an inconsistency. Google may not penalize you for cloaking, but you risk losing relevance and user trust.

How to check if your site is compliant?

Audit your links with onclick to ensure that each href points to a real and indexable URL. Use Search Console to identify crawl errors or pages indexed with unexpected content. If Googlebot encounters inconsistencies, you will see signals in coverage or indexing reports.

Also test the user experience: disable JavaScript in your browser and check that links remain functional. If your site becomes unusable without JavaScript, you create a risky dependency — and make it more difficult for Googlebot, which may not always execute your code correctly.

  • Every link with onclick must have a valid href pointing to a real URL.
  • The content displayed via onclick must match the expectations created by the href.
  • Test your pages with Googlebot Fetch and Render to check the consistency of crawled and displayed content.
  • Avoid empty hrefs, anchored (#), or javascript:void(0) — Google cannot crawl these destinations.
  • Regularly audit your links with onclick to detect inconsistencies between href and displayed content.
  • Ensure your site remains functional with JavaScript disabled to guarantee accessibility for Googlebot.
These technical optimizations may seem simple in theory, but their implementation requires close coordination between SEO and developers, especially on complex sites with advanced JavaScript frameworks. If your team lacks resources or specialized skills to audit and correct these critical points, it may be wise to engage a specialized SEO agency that can identify inconsistencies, propose suitable technical solutions for your stack, and ensure that your JavaScript implementations remain compatible with Google's requirements — without compromising user experience.

❓ Frequently Asked Questions

Un lien avec onclick et preventDefault est-il considéré comme un lien valide par Google ?
Oui, à condition que le href soit présent et valide. Google crawle le href, pas l'événement onclick. L'utilisation de preventDefault pour empêcher la navigation par défaut n'est pas problématique tant que le contenu affiché reste cohérent avec les attentes.
Puis-je utiliser onclick pour afficher du contenu dans une modale sans risquer une pénalité pour cloaking ?
Oui, tant que le contenu affiché dans la modale correspond à ce que le href promet. Si le lien annonce « Voir les détails » et que la modale affiche les détails, c'est acceptable. Si elle affiche un contenu sans rapport, Google peut considérer cela comme trompeur.
Google indexe-t-il le contenu affiché uniquement via onclick ?
Pas nécessairement. Google crawle le href, et peut exécuter le JavaScript pour indexer le contenu affiché. Mais l'indexation n'est pas garantie, surtout si le contenu n'est pas accessible via le href ou si le budget de crawl est limité.
Un href vide avec un onclick qui affiche du contenu est-il acceptable pour le SEO ?
Non. Sans href valide, Google ne peut pas crawler la destination du lien. Le lien perd tout bénéfice SEO, même si l'onclick affiche du contenu pertinent. Un href valide est indispensable pour que Google considère l'élément comme un lien.
Comment vérifier que mes liens avec onclick sont correctement crawlés par Google ?
Utilise Googlebot Fetch and Render dans la Search Console ou des outils comme Screaming Frog en mode JavaScript. Compare le contenu crawlé au contenu affiché via onclick pour détecter les incohérences. Vérifie aussi que les href pointent vers des URL réelles et indexables.
🏷 Related Topics
Domain Age & History Content Links & Backlinks Penalties & Spam

🎥 From the same video 6

Other SEO insights extracted from this same Google Search Central video · duration 20 min · published on 23/06/2020

🎥 Watch the full video on YouTube →

Related statements

💬 Comments (0)

Be the first to comment.

2000 characters remaining
🔔

Get real-time analysis of the latest Google SEO declarations

Be the first to know every time a new official Google statement drops — with full expert analysis.

No spam. Unsubscribe in one click.