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?

1
  • 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. Jan 27, 2017 at 12:03

1 Answer 1

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.

2
  • Sounds plausible.. is this documented somewhere, or is it from personal experience?
    – Emmett
    Jan 21, 2017 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, 2017 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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