Skip to main content

A launch-day SEO check for Shopify migrations: one Python script, four tests

Updated 4 min readMarkdown

On a Shopify migration, the redirect map gets all the attention. But we've seen plenty of launches where the map was perfect and rankings still dipped, because something else slipped through on launch day: a stray noindex, a canonical pointing at the staging domain, or a redirect chain three hops long.

So on launch day we run one script against the live store. It checks four things for every URL in the old site's sitemap, and it takes a few minutes for a typical store. Here's the script and the reasoning behind each test.

The four tests

  1. Each old URL redirects once, with a 301, to a page that returns 200. Chains (301 → 301 → 200) waste crawl budget and slow users. Loops and 404s lose the page's rankings outright.
  2. The destination isn't blocked from indexing. No noindex in a meta robots tag or in an X-Robots-Tag header.
  3. The canonical points at itself on the live domain. Not at *.myshopify.com, not at a staging host, not at the old platform's URL.
  4. The title isn't empty or a theme default. A blank or generic title on a product that used to rank is an easy loss.

The script

# launch_check.py — run against the live store on launch day
import csv, re, sys
import requests
from xml.etree import ElementTree as ET

NEW_HOST = "www.example-store.com"           # the live Shopify domain
OLD_SITEMAP = "old-sitemap.xml"              # saved from the old site BEFORE launch
UA = {"User-Agent": "launch-check/1.0"}

def old_urls(path):
    ns = {"s": "http://www.sitemaps.org/schemas/sitemap/0.9"}
    return [loc.text.strip() for loc in ET.parse(path).getroot().iterfind(".//s:loc", ns)]

def check(url):
    r = requests.get(url, headers=UA, allow_redirects=True, timeout=20)
    hops = [h.status_code for h in r.history]
    html = r.text[:200_000]
    robots = (re.search(r'<meta[^>]+name=["\']robots["\'][^>]+content=["\']([^"\']+)', html, re.I) or [None, ""])[1]
    canon = (re.search(r'<link[^>]+rel=["\']canonical["\'][^>]+href=["\']([^"\']+)', html, re.I) or [None, ""])[1]
    title = (re.search(r"<title>(.*?)</title>", html, re.I | re.S) or [None, ""])[1].strip()
    problems = []
    if hops != [301]:
        problems.append(f"redirect hops {hops or 'none'}")
    if r.status_code != 200:
        problems.append(f"final status {r.status_code}")
    if "noindex" in robots.lower() or "noindex" in r.headers.get("X-Robots-Tag", "").lower():
        problems.append("noindex")
    if canon and NEW_HOST not in canon:
        problems.append(f"canonical {canon}")
    if canon and canon.rstrip("/") != r.url.split("?")[0].rstrip("/"):
        problems.append("canonical not self")
    if not title or title.lower() in {"home", "products", "shop"}:
        problems.append(f"weak title '{title}'")
    return r.url, problems

if __name__ == "__main__":
    out = csv.writer(sys.stdout)
    out.writerow(["old_url", "final_url", "problems"])
    for u in old_urls(OLD_SITEMAP):
        try:
            final, probs = check(u)
        except requests.RequestException as e:
            final, probs = "", [f"error {e.__class__.__name__}"]
        if probs:
            out.writerow([u, final, "; ".join(probs)])

Run it as python launch_check.py > problems.csv. An empty file (header only) is the goal.

Notes from real launches

Save the old sitemap before DNS changes. Once the domain points at Shopify, the old sitemap.xml is gone. We save it, plus a crawl export, during the planning phase.

"Redirect hops: none" usually means a URL that didn't change. Shopify's home page and some pages keep the same path. Those show up because the test expects one 301. Filter them out or treat them as fine if the final status is 200.

Shopify only redirects URLs that don't exist. Shopify's URL redirects apply when the old path returns a 404 on the new store, so a redirect for a path that now has a live page won't fire. If an old URL lands on the wrong page, check whether a live page with the same path is catching it first. (Redirects are managed under Content › Menus › View URL redirects in current Shopify admin.)

Canonicals to the myshopify domain usually come from a custom theme snippet that hard-codes shop.permanent_domain. Shopify's own {{ canonical_url }} uses the primary domain.

Rate-limit yourself. For large catalogues, add a short sleep or a small thread pool. Shopify's storefront will throttle aggressive crawling.

What to do with the output

  • Fix redirect chains by pointing the first rule straight at the final URL.
  • Fix any noindex immediately; it's often a password page or an app setting left on.
  • Re-run the script after each fix, then submit the new sitemap in Google Search Console and watch the Pages report over the next few weeks.

FAQ

Can I run this before launch? Yes, against a preview of the new store if your redirect rules are already loaded, but the canonical test only becomes meaningful on the live domain.

Does a single 302 hurt? Use 301 for permanent moves. Google can treat long-lived temporary redirects as permanent, but there's no reason to rely on that during a migration.

How long should I keep the redirects? Indefinitely, if you can. Old links from other sites keep sending visitors and signals for years.

The full step-by-step process (crawl, URL map, content checks and the first 30 days) is in our Shopify SEO migration guide.

About the author

  • Dzimark is a website, mobile app and AI development company for businesses in the USA, UK, Canada and Australia: Shopify and WooCommerce stores, React and Next.js websites, iOS/Android/Flutter apps, AI chatbots, AI agents and automation. Offices in Dallas (USA) and Oshawa (Canada). https://dzimark.com/

No comments yet. Be the first to comment.