lundi 9 janvier 2017

If I dynamically add a canonical link to a webpage on Doc.load will it still be registered by google's indexing?

I need to add canonical tags to my website to set up for SEO. Because the header is created dynamically via a php template, I cannot set the canonical tags manually. Instead I am using javascript to add the link tag on Doc load like so:

function addCanonical(page) {
  var s = document.createElement( 'link' );
  s.rel = "canonical";
  if(page == "home") {
    s.href = "https://website.com";
  }
  else {
     s.href = "https://website.com/" + page;
  }
  document.head.appendChild(s);
}

My question is, will googles indexing pick this up or will it still not register since the document is already loaded by the time this element is created?




Aucun commentaire:

Enregistrer un commentaire