Can JavaScript change the canonical tag?
Rubric check: JavaScript that changes the canonical (check id js_changed_canonical)
It can, but it shouldn't. When the canonical in the server HTML differs from the one after JavaScript runs, search engines get two answers, and Google may pick either one.
Why it matters for SEO
Google's JavaScript guide says not to use JavaScript to change the canonical to something different from the one in the HTML. Google may read the first, the second, or neither.
This usually comes from a single-page app that sets the canonical on load, or a script that adds tracking or language parameters to it.
Does this matter for ChatGPT and AI Overviews?
Most AI crawlers read only the server HTML, so they see the first canonical and never the second. Search engines may index the other one. The page AI tools treat as the main version can then differ from the one Google ranks.
The effect is small on its own, but it splits signals that should point at one URL.
How Rubric scores it
StandardStandard checks are the baseline every other tier is measured against.
Why this tier: JS rewrites the canonical.
It is judged on every page Rubric scores.
Every Rubric score starts at 100. When this check fails, it takes up to 12 points off. Even one failing page costs at least 6 points (half of the most), and the rest comes off as the share of affected pages grows. A warning costs less than a failure.
This check doesn't cap your score. It only takes off its own points.
From the engine's scoring files, scoring 2026-v2.1 (engine d5c591d).
How common it is
Found on 3 of 277 sites where Rubric could judge it (1.1%). That is 3 of 265 judged sites in Rubric's 313-site test set and 0 of 12 sites audited on Rubric between 11 Nov 2026 and 17 Nov 2026 under the current check rules (scoring 2026-11k or later). Measured 17 Nov 2026 with scoring 2026-v2.1.
How accurate the check is
Lab test: passed. On test pages built with this problem, it caught 2 of 2. On clean test pages, it stayed quiet 1 of 1 times. (Engine build bbcec7c.)
Real sites: people checked 16 of its findings by hand and 10 were wrong (62%). Last checked 14 Nov 2026. That's a small sample, so treat the rate as rough.
Lab as of 16 Nov 2026; judged findings as of 15 Nov 2026.
How to fix it
WordPress
- View the page source (the server version) and compare the canonical with the one in your browser's Elements panel (after JavaScript).
- If they differ, a plugin or theme script is changing it. Disable plugins one at a time to find it, or check custom scripts added through a header-and-footer plugin.
- Let your SEO plugin set the canonical and remove the script's change.
Shopify
- Compare the canonical in View page source with the one in the browser's Elements panel.
- If an app changes it after load (often a currency, language or filter app), check that app's settings or ask its developer.
- Keep the theme's
{{ canonical_url }}tag as the only canonical.
Webflow
- Webflow prints the canonical in the server HTML from your SEO settings.
- If it changes after load, look for a script in Site settings > Custom code or the page's Custom code that edits
link[rel=canonical], and remove it. - Set the canonical in SEO settings > Page canonical URL instead. Publish.
Custom code
Render the final canonical on the server and don't touch it in client code:
<link rel="canonical" href="https://example.com/page">In frameworks (Next.js, Nuxt and similar), set it in the server-rendered head, not in an effect that runs after load.