5

I have a single-page app, i.e. page navigation and url changes happen with javascript, rather than full page loads.

Additionally, occasionally multiple variants of a url point to the same underlying page. So, I'd like to add canonical link elements to define which url is canonical.

Do I need to keep the canonical link element up-to-date at all times in the DOM as the url changes, or is it sufficient to set it once on page load and then leave it alone?

  • I think you could just leave it alone. I'm pretty sure that Googlebot justs loads the URL and looks once it is loaded. Googlebot is going to note the URLs and fully download next pages rather than try to browse around within the site without reloading. I'm just speaking theoretically though, I've never tested it or seen anybody else do so. – Stephen Ostermiller Jan 27 '17 at 12:03
1

If the dynamic URLs are indexed by the search engine, yes, you should keep the canonical link element up-to-date. This could be made from the template which is rendered, and would always include the same canonical for that content.

  • Sounds plausible.. is this documented somewhere, or is it from personal experience? – Emmett Jan 21 '17 at 8:43
  • @Emmett - Well, canonical element is used for avoiding duplicated content in your website. If Google indexes two URLs with the same content, it will be considered duplicated. On the other hand, Google will try to index all your pages (you may provide a sitemap), so if you have more than one URL for the same content, you should always use canonical element. It's more common sense. – Manolo Jan 21 '17 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.