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


Community answers

No community answers yet.

Log in to answer Members can add their own answer and like others.


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