Learn how to delete the ?m=1 parameter from your Blogger website URLs to improve indexing and improve your blog's speed.
Why does Blogger display ?m=1 in Mobile URL
Method 1(Client side): Remove ?m=1 from Blogger using Javascript and History API
Follow these steps to remove the ?m=1 parameter from the blogger blog URL;
- Steps #1: log in to your Blogger dashboard and click on the Theme section
- Steps #2: Click on Edit HTML to modify your theme code
- Steps #3: Add the following script immediately below the
<head>
tag in your HTML code<script type='text/javascript'> //<![CDATA[ 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>
- Steps #4: To complete the process, save the code and reload your blog. Once done, the "?m=1" parameter will be automatically removed from Blogger URLs for mobile requests.
However, If the previous code doesn't work, delete it and use the following alternative code to remove the ?m=1 parameter from mobile Blogger URLs.
<script>
/*<![CDATA[*/ 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>
Method 2(Server side): Prevent redirection from server side using Cloudflare Workers as middleware
This method is based on the work of Deo Kumar, a web developer from India and creator of the widely-used "Plus UI" Blogger theme. I hereby acknowledge that the code utilized in this method is the property of Deo Kumar, and credit is duly given.
Source:
https://www.fineshopdesign.com/
Step 1: Create a Worker in Cloudflare
#A. Login to your Cloudflare Account.
#B. Go to Workers & Pages section and Create a worker.


#C. Rename worker as prevent-m-redirect-blogger
and deploy


#D. Edit code replace the existing code with the following code and redeploy code
/**
* Environment interface
*
* @typedef Env
* @property {string} my_var
*/
// constants
const MOBILE_REGEX = /(?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera\ mini|avantgo|mobilesafari|docomo|KAIOS)/i;
const TABLET_REGEX = /(?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))/i;
/**
* A helper function to get the device type from user-agent
*
* @param {string | null} userAgent
*
* @returns {"mobile" | "tablet" | "desktop"}
*/
const getDeviceType = (userAgent) => {
if (typeof userAgent === "string") {
if (MOBILE_REGEX.test(userAgent)) {
return "mobile";
}
if (TABLET_REGEX.test(userAgent)) {
return "tablet";
}
}
// Everything else not matched above will be considered as desktop
return "desktop";
}
/**
* An object with workers handlers
*
* @type {ExportedHandler<Env>}
*/
const worker = {
async fetch(request, env, context) {
// Get the device type from user-agent header
const deviceType = getDeviceType(request.headers.get("User-Agent"));
const proxiedUrl = new URL(request.url);
// Set the search param 'm' with value '1' if the device type is not 'desktop'
if (deviceType !== "desktop") {
proxiedUrl.searchParams.set("m", "1")
}
const proxiedRequest = new Request(proxiedUrl, {
method: request.method,
body: request.body,
headers: request.headers,
redirect: "follow"
});
const proxiedResponse = await fetch(proxiedRequest);
const response = new Response(proxiedResponse.body, proxiedResponse);
// OPTIONAL: You can further modify the response here :)
return response;
}
}
// Export handlers
export default worker;


Step 2: Add a new Routes
#A. Select your domain on the cloudflare dashboard

#B. Now go to Workers Routes section and then click on Add Route

#C. Input the fields as shown in the given table:
Route | Service | Environment |
---|---|---|
www.fineshopdesign.com/* |
prevent-m-redirect-blogger |
production |

Frequently Asked Questions
Does removing “?m=1” affect your Blog SEO and improve Blogger speed?
text_here
Should you remove “?m=1” from the blogger URL
text_here