JavaScript changes the canonical to a different URL
canonical_changed_by_jsShort answer
The server-sent HTML has a canonical tag pointing to one URL, and after JavaScript runs the canonical points to a different URL. Google sees two different canonicals, one before and one after JavaScript, and the result is unpredictable. Set the canonical once, in the original HTML, and don't change it with JavaScript. Google says JavaScript may add a canonical that is missing from the HTML, but shouldn't change it to a URL other than the one in the original HTML.
Why it matters
Canonical selection is how Google decides which URL to index and where to consolidate signals. Conflicting canonicals are treated as a weak signal, and Google falls back to its own judgment, which may pick a URL you did not intend (a parameterised copy, the non-www host, a paginated page).
How Glimana detects it
Glimana compares the canonical URL in the raw HTML with the one in the rendered DOM for pages checked in the last 14 days. The rule fires when both exist and differ (JavaScript adding a canonical where there was none is allowed and not reported). The evidence shows both values.
How to fix it
Two plugins are emitting canonicals (for example the SEO plugin server-side and an AMP, language or A/B plugin via script), or a theme script rewrites it to strip parameters. Keep only the SEO plugin's canonical and disable the other output.
The theme sets canonical_url in Liquid; an app (currency switcher, personalisation) then rewrites it. Disable the app's canonical feature.
In SPAs, the router often updates the canonical on client navigation; make sure the initial server HTML already carries the correct canonical for the requested URL, and that the client-side value is identical for the initial route.
How the fix is verified
Re-crawl; the task closes when the raw and rendered canonicals match.