Official statement
Other statements from this video 25 ▾
- □ Does Google really experience delays in discovering JavaScript links?
- □ Why does Google ignore your canonical tags when the raw HTML contradicts the rendered output?
- □ Does a raw HTML noindex really prevent JavaScript rendering by Google?
- □ Can you really modify title, meta, and links on the client side with JavaScript without risks?
- □ Is client-side JavaScript really holding back your SEO performance?
- □ Raw HTML vs Rendered: Does Google really not care?
- □ Does Google AdSense really penalize your site's speed like any other third-party script?
- □ Should you be worried about 'other error' issues with images in the Search Console?
- □ Should you prioritize user agent or viewport detection for your separate mobile versions?
- □ Do JavaScript navigation links really affect your site's SEO?
- □ Does Google really use different crawlers for its SEO testing tools?
- □ Are the structured data from your mobile version also applicable to desktop?
- □ Should you really stop fearing JavaScript for SEO?
- □ Do JavaScript links really slow down Google's discovery process?
- □ How can a different canonical tag between raw HTML and rendered output destroy your canonicalization strategy?
- □ Can you really remove a noindex via JavaScript without risking de-indexation?
- □ Is it truly safe to modify meta tags and links with JavaScript without risking your SEO?
- □ Do Google products really get a hidden SEO advantage in search results?
- □ Should you be concerned about 'other' errors in the URL Inspection Tool?
- □ Does Google really overlook your images during web search rendering?
- □ User agent or viewport: Does Google really differentiate for mobile indexing?
- □ Do JavaScript-generated links truly pass ranking signals like traditional HTML links?
- □ Can an empty HTML canonical tag mistakenly force Google to auto-canonicalize your page?
- □ Can the Mobile-Friendly Test really substitute the URL Inspection Tool for auditing mobile crawling?
- □ Why does Google ignore your desktop structured data after switching to mobile-first indexing?
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 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.
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.
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" 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.
How does Google handle JavaScript changes to the canonical tag?
What is the recommended alternative from Google?
<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.
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.
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%.
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.
What nuances should be added to this recommendation?
In what cases does this rule not fully apply?
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 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 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).
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.
<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.
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?
How can I check that my site is compliant after correction?
❓ Frequently Asked Questions
Une balise canonical vide est-elle équivalente à l'absence de balise canonical ?
Si mon JavaScript remplit la canonical en 50 ms, Googlebot voit-il la bonne valeur ?
Peut-on utiliser une canonical vide temporairement pendant un refactoring ?
Les autres moteurs (Bing, Yandex) gèrent-ils ce cas comme Google ?
Comment tester si ma canonical est bien définie avant le JavaScript ?
🎥 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.