Mobile app version of vmapp.org
Login or Join
LarsenBagley505

: Can I declare a duplicate page via javascript for google? Most sources of documentation state that one can declare a webpage a duplicate of another by applying this tag on the duplicate page:

@LarsenBagley505

Posted in: #CanonicalUrl #DuplicateContent #Javascript #RelCanonical

Most sources of documentation state that one can declare a webpage a duplicate of another by applying this tag on the duplicate page:

<link rel="canonical" href="(absolute URL to original page)">


I could generate the above tag via the script below:

<script>
var l=document.createElement('Link');
l.rel='canonical';l.href='(absolute URL to original page)';
document.getElementsByTagName('head')[0].appendChild(l);
</script>


My question is, would google be able to process this javascript and believe I'm declaring the page as a duplicate page? or would I be forced to use the link tag in the header?

I ask because I'm trying to reduce the unnecessary bytes required to be processed before the actual user readable content begins.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @LarsenBagley505

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shelton105

Firstly the use of canonical:

The use of canonical is not exactly creating duplicate pages. Every application should avoid creating duplicate pages.
1)Canonical is meant to give seo wieghtage to the main or parent page from which it is derived.

2)This needs not to be exact duplicate, but this means this new page is also generating similar information with the canonical.

3)
This is lot used in blogging/news sites where i want to publish content from other sources to my site and give credits to the actual owner

4) Also used in cases like running a site on both http and https and you take one of them as base for seo crawling. So you add that to another as canonical.

Other useful cases as well exists which make canonical a very important tag and should be used carefully

Adding Canonical via javascript

Though google crawlers are now becoming intelligent enough to understand javascript. But this should be done with best implementation practices and recommendations, otherwise you end up messing with your seo health. As if google does not read canonical properly, you end up penalizing for duplicate content.
developers.google.com/webmasters/ajax-crawling/docs/learn-more
Unnecessary content for user, saving space - Useless in described case

The required seo tags don't add up that much which will hurt you front-end performance or help reducing network transfer time.
Yes if you want to tune your page such that you pass all crawler related + most important components of your site in first load, and then load content on demand via ajax then you should go ahead but following best practices if you want that content to be seo friendly.

But for canonical addition via javascript just to save few bytes of transfer is not recommended.

10% popularity Vote Up Vote Down


 

@Vandalay111

yes, Google is able to proceed Javascript, even if it fires after onload, if you add your script on the bottom of the file and add something like window.addEventListener('load', l);.


placing the adsense code closer to the beginning of the HTML code means more money


In my opinion, the plan is useless, because your page with duplicated content will never get good AdSense scoring, even if you make the distance from the page beginning to the AdSense one code line shorter.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme