Peace be upon you friends!
In today's post I am going to tell you all about the code required to remove extra content in blogger links. Often when you open a blogger based website on your mobile, you will see something written next to the link as shown below.
https://yourblogurl/m=0 OR https://yourblogurl/m=1
Such links can cause problems in page indexing. If it is not removed, many pages will not get indexed due to redirect error and sometimes won't even get AdSense approval.
So guys, below is the code to solve this problem.
This is the Code for the subject
<script type='text/javascript'>
var uri = window.location.toString();
if (uri.indexOf("%3D","%3D") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("%3D"));
window.history.replaceState({}, document.title, clean_uri);
}
var uri = window.location.toString();
if (uri.indexOf("%3D%3D","%3D%3D") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("%3D%3D"));
window.history.replaceState({}, document.title, clean_uri);
}
var uri = window.location.toString();
if (uri.indexOf("&m=1","&m=1") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("&m=1"));
window.history.replaceState({}, document.title, clean_uri);
}
var uri = window.location.toString();
if (uri.indexOf("?m=1","?m=1") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("?m=1"));
window.history.replaceState({}, document.title, clean_uri);
}
</script>
This code has to be added below the </head> tag inside the blogger theme's html. This will remove the extra canonical in the blogger link. And page indexing will not be a future problem.
0 Comments: