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

An empty canonical tag in the initial HTML that is then filled by JavaScript can cause involuntary auto-canonicalization of the page. It is better to either not include the tag at all or to create it entirely via JavaScript if necessary.
🎥 Source video

Extracted from a Google Search Central video

💬 EN 📅 26/04/2021 ✂ 26 statements
Watch on YouTube →
Other statements from this video 25
  1. Les liens JavaScript retardent-ils vraiment la découverte par Google ?
  2. Pourquoi Google ignore-t-il vos balises canoniques quand le HTML brut contredit le rendu ?
  3. Le noindex en HTML brut empêche-t-il définitivement le rendu JavaScript par Google ?
  4. JavaScript et SEO : peut-on vraiment modifier title, meta et liens côté client sans risque ?
  5. Le JavaScript côté client est-il vraiment un frein pour vos performances SEO ?
  6. HTML brut vs rendu : Google s'en fiche-t-il vraiment ?
  7. Google AdSense pénalise-t-il vraiment la vitesse de votre site comme n'importe quel script tiers ?
  8. Faut-il s'inquiéter des erreurs 'other error' sur les images dans la Search Console ?
  9. User agent ou viewport : quelle détection privilégier pour vos versions mobiles séparées ?
  10. Les liens de navigation JavaScript affectent-ils vraiment le référencement de votre site ?
  11. Quel crawler Google utilise vraiment ses outils de test SEO ?
  12. Les données structurées de votre version mobile s'appliquent-elles aussi au desktop ?
  13. Faut-il vraiment arrêter de craindre le JavaScript pour le SEO ?
  14. Les liens JavaScript retardent-ils vraiment la découverte par Google ?
  15. Pourquoi une balise canonical différente entre HTML brut et rendu peut-elle ruiner votre stratégie de canonicalisation ?
  16. Peut-on vraiment retirer un noindex via JavaScript sans risquer la désindexation ?
  17. Peut-on vraiment modifier les balises meta et les liens en JavaScript sans risque SEO ?
  18. Les produits Google bénéficient-ils d'un avantage SEO caché dans les résultats de recherche ?
  19. Faut-il s'inquiéter des erreurs 'other' dans l'outil d'inspection d'URL ?
  20. Google ignore-t-il vraiment vos images lors du rendu pour la recherche web ?
  21. User agent ou viewport : Google fait-il vraiment la différence pour l'indexation mobile ?
  22. Les liens générés en JavaScript transmettent-ils vraiment les signaux de ranking comme les liens HTML classiques ?
  23. Une balise canonical vide en HTML peut-elle forcer Google à auto-canonicaliser votre page par erreur ?
  24. Le Mobile-Friendly Test peut-il remplacer l'URL Inspection Tool pour auditer le crawl mobile ?
  25. Pourquoi Google ignore-t-il vos données structurées desktop après le mobile-first indexing ?
📅
Official statement from (5 years ago)
TL;DR

Leaving a canonical tag with an empty href attribute in the initial HTML and then filling it via JavaScript can trigger involuntary auto-canonicalization. Google recommends either setting the canonical directly on the server or creating the complete element via JavaScript without leaving an empty tag. This practice, often used to simplify dynamic templates, can generate contradictory signals for the crawler.

What you need to understand

Why is an empty canonical tag problematic?<\/h3>

When the initial HTML contains <link rel="canonical" href=""><\/code><\/strong>, Googlebot interprets this tag before JavaScript even executes. An empty value in the href<\/strong> attribute is technically resolved as a reference to the page itself, which triggers auto-canonicalization.<\/p>

The issue is that this self-reference is not always the developer's intention. If the script later fills this tag with a different URL — for example, to point to a consolidated version —, Google has already recorded the first value<\/strong>. The signal becomes contradictory, and the engine has to arbitrate between two directives.<\/p>

How does Google handle JavaScript changes to the canonical tag?<\/h3>

Google executes JavaScript and can therefore see the final value after hydration. But timing is crucial: if the crawler indexes the page before the script completes execution<\/strong>, or if JavaScript rendering fails for any technical reason, it is the empty tag that prevails.<\/p>

Martin Splitt reminds us that even in a well-optimized JavaScript environment, there’s a moment when the raw HTML is parsed. It is this initial HTML that anchors the first signals<\/strong>: hreflang, canonical, meta robots. Relying solely on JS to correct these critical elements introduces a structural risk.<\/p>

What is the recommended alternative from Google?<\/h3>

Two options emerge. The first: set the canonical on the server<\/strong>, directly in the initial HTML, with the correct value. This is the most robust solution, which eliminates any ambiguity and ensures that all crawlers — including those that do not execute JavaScript — capture the correct signal.<\/p>

The second option, for architectures where this is impossible: do not include the tag at all<\/strong> in the initial HTML, and create it entirely via JavaScript. No <link rel="canonical"><\/code> left empty, but a complete injection of the DOM element with all its attributes filled upon insertion. This avoids the intermediate phase where an incomplete tag exists in the DOM.<\/p>

  • Empty canonical tag in the HTML<\/strong> = risk of involuntary auto-canonicalization<\/li>
  • Google reads the initial HTML before the JavaScript<\/strong> and can log the empty value as a directive<\/li>
  • Solution 1<\/strong>: set the canonical on the server with the correct value at the initial render<\/li>
  • Solution 2<\/strong>: do not include the tag at all, then create it entirely via JavaScript if necessary<\/li>
  • Never leave a canonical tag with an empty href<\/strong> in production, even temporarily<\/li>

SEO Expert opinion

Is this statement consistent with observed practices in the field?<\/h3>

Absolutely. We regularly see sites with a hybrid SPA or SSR architecture<\/strong> leaving empty meta, canonical, or hreflang tags in the HTML shell, then filling them via React, Vue, or Angular. The result? Unexplainable indexing fluctuations, randomly consolidated URLs, or worse: pages that self-canonicalize when they should point to a hub version.<\/p>

What Splitt doesn’t explicitly state — but what every practitioner knows — is that not all crawlers are equal<\/strong> when it comes to JavaScript. Googlebot executes JS, certainly, but with a limited crawl budget and variable timeouts. Bing, Yandex, social media bots? Much less reliable. An empty canonical is a corrupted signal for a considerable portion of traffic and social signals.<\/p>

What nuances should be added to this recommendation?<\/h3>

The recommendation is clear for traditional sites<\/strong>, but in Jamstack or client-side Next.js architectures, there’s a gray area. If the SSR is well configured, the canonical tag should never be empty<\/strong> in the HTML served to the bot. It’s a matter of framework-side configuration, not a technical limitation.<\/p>

However, if you’ve inherited a legacy where redoing server-side templating costs three sprints, the solution of not injecting the tag at all and then creating it via JS remains a fragile compromise<\/strong>. [To be verified]<\/strong> on high-volume sites: does Googlebot systematically index after complete JS execution, or could there be cases where the crawler switches to a “light” mode and skips rendering? No public data confirms this guarantee 100%.<\/p>

In what cases does this rule not fully apply?<\/h3>

If your page does not need a canonical<\/strong> — because it is unique, without variants, without pagination — then the absence of a tag is not an issue. Google defaults to considering a page without a canonical as self-canonical. No empty tag, no risk.<\/p>

But as soon as you manage syndicated content, e-commerce filters, distinct AMP or mobile versions, or multilingual content, the canonical becomes a critical signal<\/strong>. In these contexts, leaving it empty even for 200 ms is like leaving a flashing red light: you introduce uncertainty into a system that needs clarity.<\/p>

Be cautious of headless CMSs that generate a uniform HTML shell for all pages and then inject content via API + JS. Ensure that critical tags (canonical, hreflang, meta robots) are properly hydrated on the server side or via SSR, not just client-side.<\/div>

Practical impact and recommendations

What should you do concretely if you have empty canonicals in production?<\/h3>

Start by auditing. Use "View Source"<\/strong> (Ctrl+U) on your strategic URLs, not the inspector. If you see <link rel="canonical" href=""><\/code> or <link rel="canonical"><\/code> without an attribute, it’s a bug that needs immediate correction. Then compare with the inspector after full loading: if the tag changes, you confirm that JS is involved.<\/p>

Next, prioritize according to the architecture. If you control the server<\/strong> (PHP, Node, Python, etc.), generate the canonical directly in the server-side template. This is the cleanest and most sustainable solution. If you are in modern SSR (Next.js, Nuxt), ensure that getServerSideProps<\/code> or the equivalent properly injects the tag with the correct value before sending the HTML to the bot.<\/p>

What mistakes should you avoid when correcting this?<\/h3>

Do not replace an empty tag with a late JavaScript injection without testing the rendering timing<\/strong>. If your script loads in defer or async and Googlebot snapshots the page beforehand, you’ve gained nothing. Test with Search Console (URL inspection) or a tool like Screaming Frog in “render JavaScript” mode to verify that the canonical appears correctly in the final DOM viewed by Google.<\/p>

Another pitfall: creating the tag via JS but forgetting to manage dynamic parameters<\/strong> (UTM, session ID, etc.). If your script injects the canonical with the current URL without cleaning it, you lose all the directive’s value. Ensure that the JavaScript or server logic normalizes the URL (removes unnecessary parameters, enforces HTTPS, consistent trailing slash).<\/p>

How can I check that my site is compliant after correction?<\/h3>

Perform a complete crawl with Screaming Frog or Sitebulb<\/strong> in JavaScript rendering mode. Export the "Canonical Link Element 1" column and check that there are no empty rows, no involuntary self-references. Compare with a crawl without JS: if differences appear, it means you still depend on JavaScript for critical signals.<\/p>

Also use Google Search Console<\/strong>: inspect 10-15 representative URLs (homepage, categories, products, articles). Look at the “Coverage” section > “Inspected URL” > “HTML retrieved.” If the canonical appears correctly filled, you’re good. If it’s absent or empty, the issue persists on the Googlebot rendered side.<\/p>

  • Audit the raw HTML (View Source) for detecting empty canonical tags<\/li>
  • Generate the canonical on the server or via SSR, never just client-side<\/li>
  • If JS injection is necessary: create the complete element, not an empty tag to fill<\/li>
  • Test Google's rendering with Search Console (URL inspection) and Screaming Frog (JS rendering)<\/li>
  • Ensure the canonical normalizes the URL (no irrelevant parameters, consistent protocol)<\/li>
  • Compare crawl with/without JS to identify critical dependencies on JavaScript<\/li>
Correcting empty canonical tags may seem trivial, but in modern environments (headless CMS, JS frameworks, CDN edge rendering), the technical implementation can quickly become complex. Between SSR, hydration, CDN cache, and edge workers, there are multiple potential breakpoints. If your infrastructure relies on these advanced architectures, assistance from a specialized SEO agency can spare you months of indexing fluctuations and ensure a robust compliance from the first deployment.<\/div>

❓ Frequently Asked Questions

Une balise canonical vide est-elle équivalente à l'absence de balise canonical ?
Non. Une balise canonical avec href vide est interprétée comme une auto-référence (canonical vers la page elle-même), alors qu'une absence totale de balise laisse Google décider librement quelle URL canonique choisir. Les deux situations sont différentes pour le crawler.
Si mon JavaScript remplit la canonical en 50 ms, Googlebot voit-il la bonne valeur ?
Pas toujours. Google peut indexer la page avant ou pendant l'exécution du JavaScript, surtout si le crawl est ralenti par le budget ou des timeouts. Le HTML initial fait foi dans de nombreux cas, même si le rendu final est correct.
Peut-on utiliser une canonical vide temporairement pendant un refactoring ?
C'est fortement déconseillé. Même sur une courte période, Google peut crawler et enregistrer cette directive incohérente. Mieux vaut désactiver temporairement l'indexation (meta robots noindex) ou bloquer le crawl le temps de finaliser la correction.
Les autres moteurs (Bing, Yandex) gèrent-ils ce cas comme Google ?
Bing exécute aussi le JavaScript, mais avec moins de garanties de timing et de profondeur que Google. Yandex et les crawlers sociaux sont encore plus aléatoires. Compter sur le JS pour des signaux critiques est risqué au-delà de Google.
Comment tester si ma canonical est bien définie avant le JavaScript ?
Utilise "Afficher le code source" (Ctrl+U ou View Source) dans ton navigateur, ou curl l'URL depuis un terminal. Si la balise canonical est absente ou vide dans cette réponse brute, elle dépend du JavaScript et pose potentiellement problème pour les crawlers.

🎥 From the same video 25

Other SEO insights extracted from this same Google Search Central video · published on 26/04/2021

🎥 Watch the full video on YouTube →

💬 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.