JavaScript rendering · Raw and rendered HTML
Canonical changed by JavaScript
The raw HTML canonical on this page points at itself, but a script changes it to point at another page once the page loads in a browser.
How this page is built
The server sends a self-referencing canonical. A script in the head then rewrites its href to the canonical target page. A crawler that reads only the raw HTML sees a self-referencing canonical, and one that renders the page sees a canonicalised page.
Why it matters
Google reads the canonical twice: once in the raw HTML and again after rendering. When the two disagree, Google has to choose between them, and its documentation says not to change the canonical with JavaScript for that reason. The result is unpredictable, and the page you meant to be indexed may not be.
Canonicals changed in the browser usually come from tag managers, A/B testing tools or front-end frameworks that set head tags on every route change.
How to check it
Compare the raw HTML (view source) with the rendered HTML (the Elements panel in developer tools, or the URL Inspection tool in Search Console). Crawl tools that render JavaScript can store both versions and report differences between them. Here, the raw canonical points at this page and the rendered one points at the canonical target page.
How to fix it
Set the correct canonical in the HTML the server sends, and stop scripts from changing it. If a framework manages head tags, render them on the server.