What does Google say about SEO? /
Quick SEO Quiz

Test your SEO knowledge in 5 questions

Less than a minute. Find out how much you really know about Google search.

🕒 ~1 min 🎯 5 questions

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. □ Does Google really experience delays in discovering JavaScript links?
  2. □ Why does Google ignore your canonical tags when the raw HTML contradicts the rendered output?
  3. □ Does a raw HTML noindex really prevent JavaScript rendering by Google?
  4. □ Can you really modify title, meta, and links on the client side with JavaScript without risks?
  5. □ Is client-side JavaScript really holding back your SEO performance?
  6. □ Raw HTML vs Rendered: Does Google really not care?
  7. □ Does Google AdSense really penalize your site's speed like any other third-party script?
  8. □ Should you be worried about 'other error' issues with images in the Search Console?
  9. □ Should you prioritize user agent or viewport detection for your separate mobile versions?
  10. □ Do JavaScript navigation links really affect your site's SEO?
  11. □ Does Google really use different crawlers for its SEO testing tools?
  12. □ Are the structured data from your mobile version also applicable to desktop?
  13. □ Should you really stop fearing JavaScript for SEO?
  14. □ Do JavaScript links really slow down Google's discovery process?
  15. □ How can a different canonical tag between raw HTML and rendered output destroy your canonicalization strategy?
  16. □ Can you really remove a noindex via JavaScript without risking de-indexation?
  17. □ Is it truly safe to modify meta tags and links with JavaScript without risking your SEO?
  18. □ Do Google products really get a hidden SEO advantage in search results?
  19. □ Should you be concerned about 'other' errors in the URL Inspection Tool?
  20. □ Does Google really overlook your images during web search rendering?
  21. □ User agent or viewport: Does Google really differentiate for mobile indexing?
  22. □ Do JavaScript-generated links truly pass ranking signals like traditional HTML links?
  23. □ Can an empty HTML canonical tag mistakenly force Google to auto-canonicalize your page?
  24. □ Can the Mobile-Friendly Test really substitute the URL Inspection Tool for auditing mobile crawling?
  25. □ Why does Google ignore your desktop structured data after switching to 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?

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

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. The signal becomes contradictory, and the engine has to arbitrate between two directives.

How does Google handle JavaScript changes to the canonical tag?

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, or if JavaScript rendering fails for any technical reason, it is the empty tag that prevails.

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: hreflang, canonical, meta robots. Relying solely on JS to correct these critical elements introduces a structural risk.

What is the recommended alternative from Google?

Two options emerge. The first: set the canonical on the server, 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.

The second option, for architectures where this is impossible: do not include the tag at all in the initial HTML, and create it entirely via JavaScript. No <link rel="canonical"> 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.

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

SEO Expert opinion

Is this statement consistent with observed practices in the field?

Absolutely. We regularly see sites with a hybrid SPA or SSR architecture 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.

What Splitt doesn’t explicitly state — but what every practitioner knows — is that not all crawlers are equal 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.

What nuances should be added to this recommendation?

The recommendation is clear for traditional sites, 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 in the HTML served to the bot. It’s a matter of framework-side configuration, not a technical limitation.

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. [To be verified] 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%.

In what cases does this rule not fully apply?

If your page does not need a canonical — 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.

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

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.

Practical impact and recommendations

What should you do concretely if you have empty canonicals in production?

Start by auditing. Use "View Source" (Ctrl+U) on your strategic URLs, not the inspector. If you see <link rel="canonical" href=""> or <link rel="canonical"> 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.

Next, prioritize according to the architecture. If you control the server (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 or the equivalent properly injects the tag with the correct value before sending the HTML to the bot.

What mistakes should you avoid when correcting this?

Do not replace an empty tag with a late JavaScript injection without testing the rendering timing. 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.

Another pitfall: creating the tag via JS but forgetting to manage dynamic parameters (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).

How can I check that my site is compliant after correction?

Perform a complete crawl with Screaming Frog or Sitebulb 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.

Also use Google Search Console: 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.

  • Audit the raw HTML (View Source) for detecting empty canonical tags
  • Generate the canonical on the server or via SSR, never just client-side
  • If JS injection is necessary: create the complete element, not an empty tag to fill
  • Test Google's rendering with Search Console (URL inspection) and Screaming Frog (JS rendering)
  • Ensure the canonical normalizes the URL (no irrelevant parameters, consistent protocol)
  • Compare crawl with/without JS to identify critical dependencies on JavaScript
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.

❓ 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.
🏷 Related Topics
Domain Age & History Crawl & Indexing AI & SEO JavaScript & Technical SEO

🎥 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 →

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.