Blog Importer automatically registers Shopify’s native 301 redirects when migrating your blog posts. This ensures a smooth transfer of your search engine rankings (SEO) from your old site to your new Shopify store without any complex manual configuration.
However, there are specific URL patterns that Shopify’s native feature cannot handle.
Unsupported Pattern: URLs with Query Parameters
Shopify’s standard redirect feature has a structural limitation: it cannot accurately identify URLs that contain a ”?” (query parameters).
- Supported Example:
example.com/old-post - Supported Example (Parameters at 2nd level or deeper):
example.com/news/?pid=123 - Unsupported Example:
example.com/?pid=123(Parameterized URLs directly under the root domain)
These types of URLs cannot be redirected using Blog Importer or Shopify’s default redirect settings.
The Solution
To successfully migrate pages with these legacy URL structures, you must use client-side JavaScript to manually route visitors to the correct page in their browser.
Why is JavaScript Necessary?
Shopify’s native redirects are processed on the server side. Systemically, Shopify drops any information following a ”?” in the URL, making it impossible to conditionally route traffic based on parameter differences.
To resolve this, we need “smart routing”: JavaScript instantly reads the full URL upon page load in the visitor’s browser and dynamically redirects them to the proper destination.
How to Implement via JavaScript (Sample Code)
Place the following code inside your Shopify theme’s theme.liquid file, immediately before the closing </head> tag. Update the redirectMap variable to match your old URL parameters and their corresponding new paths.
<script>
(function() {
// Redirect map: Old URL parameters to new paths
var redirectMap = {
"?pid=123": "/blogs/news/article-a",
"?pid=456": "/blogs/news/article-b",
"?p=789": "/pages/contact"
};
var currentQuery = window.location.search;
if (currentQuery && redirectMap[currentQuery]) {
window.location.href = redirectMap[currentQuery];
}
})();
</script>