OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to handle canonical URL delivered from server in React SPA

  • Thread starter Thread starter tripRev
  • Start date Start date
T

tripRev

Guest
Google console has been complaining that my / page is a duplicate of /?utm_source=whatever. I can fix that by making sure that any time the page is requested with anything after the /, it will be delivered with a <link rel="canonical" href="https://example.org/" /> tag in the HTML.

However, the page then loads a React SPA. I believe in these modern times, Google also loads JavaScript pages and assesses them for SEO purposes. So my SPA rendered HTML doc is going to be stuck there with the wrong canonical URL in it when the user navigates like / -> /login.

There seems to be very little info about this around when surely it is a common problem? Should I just make the SPA remove any canonical link tag it sees in the HTML when it loads? Or maybe I need to go through every public route of the React app and make it insert/update the correct canonical link tag every time the user navigates?

<p>Google console has been complaining that my <code>/</code> page is a duplicate of <code>/?utm_source=whatever</code>. I can fix that by making sure that any time the page is requested with anything after the <code>/</code>, it will be delivered with a <code><link rel="canonical" href="https://example.org/" /></code> tag in the HTML.</p>
<p>However, the page then loads a React SPA. I believe in these modern times, Google also loads JavaScript pages and assesses them for SEO purposes. So my SPA rendered HTML doc is going to be stuck there with the wrong canonical URL in it when the user navigates like <code>/</code> -> <code>/login</code>.</p>
<p>There seems to be very little info about this around when surely it is a common problem? Should I just make the SPA remove any canonical link tag it sees in the HTML when it loads? Or maybe I need to go through every public route of the React app and make it insert/update the correct canonical link tag every time the user navigates?</p>
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top