Technical SEO FAQ · JavaScript SEO & Rendering

How can JavaScript affect canonical tags?

JavaScript can create or modify canonical tags.

Google can process a JavaScript-injected canonical, but Google's documentation recommends putting the canonical in the original HTML where possible and says not to use JavaScript to change the canonical to a different URL than the one specified in the original HTML.

Bad pattern:

<link rel="canonical" href="https://www.theseocentral.com/product-a">

then JavaScript changes it to:

/product-b

This introduces conflicting signals.

If JavaScript is required, the implementation should produce one consistent canonical.


Sources


Related questions


← All technical SEO questions View as Markdown (.md)