Appearance

Visual style

Mode
Theme
Accent
Advanced
Text sizeScales the whole site
16 px
Reduce motionReduce animations or match your system
Separate light and darkChoose a theme, accent and font for each
50

Performance & SEO

How to migrate a website without losing search rankings

The method I used to rebuild a large WordPress brand site as static Astro: inventory first, URLs as a contract, and tests that prove nothing was lost.

A redesign loses rankings when URLs disappear, content is dropped or pages get slower. To prevent that, inventory every URL and piece of content before designing anything, keep URLs where you can and permanently redirect the rest to the most relevant new page, then prove it with an automated test that requests every old URL against the new build. Measure performance before and after on throttled mobile, and only launch when both checks pass.

I rebuilt the Eastern Condiments website, a large WordPress brand site with a product catalogue, recipes, a cookbook, a store locator, events and statutory documents, as a static Astro site. Every one of the 442 URLs in its original sitemap is either rebuilt or redirected to a real page, and a test enforces that. Here is the method.

1. Inventory before you design

Many migration failures aren’t technical. A new design is approved, built and launched, and only afterwards does someone notice that a section of old pages had no place in the new structure.

So the first deliverable is an inventory, not a mockup:

  • Every URL from the existing sitemap, plus a crawl to catch pages the sitemap omits.
  • Every content type: products, recipes, stores, events, posts, downloadable documents.
  • Every asset that matters: product images, PDFs, archives.
  • Business facts with their source, so the new site doesn’t introduce claims the old one didn’t make.

On Eastern, the inventory produced a migration checklist, a page mapping and an asset inventory before any design work began. It also turned up content the live site hid (an unpublished statistic and a newsletter), which was deliberately kept off the new site.

2. Keep or redirect every URL

Each old URL gets one of two outcomes:

OutcomeWhenImplementation
KeptThe page still exists in the new structureSame path, same trailing-slash convention
RedirectedThe page merged into another or was retiredPermanent (301) redirect to the most relevant real page

Two details are easy to miss:

  • Match the old URL format exactly. WordPress uses trailing slashes, so the new site uses trailingSlash: "always". A mismatch turns every URL into a redirect.
  • Redirect to relevance, not the homepage. A retired product should redirect to its category or replacement. Mass-redirecting to the homepage is treated much like a missing page.

On static hosting, real 301s come from the host. The Eastern build emits a _redirects file (supported by Cloudflare Pages and Netlify) and also generates static redirect pages as a fallback for hosts that don’t read that file, so retired URLs never 404.

3. Move content as data, and test it

Copy-pasting content into templates is where details get lost. Instead:

  1. Extract content from the old site into structured files (products, recipes, stores, history).
  2. Review the extracts, and hand-check anything that can’t be extracted reliably. On Eastern, 41 cookbook cards were transcribed and checked by hand.
  3. Render pages from those files, never from text hardcoded in components.
  4. Write tests about the content itself.

The Eastern unit tests assert, among other things, that:

  • all 141 original products are present, with unique slugs and valid categories;
  • pack sizes and retailer links are byte-identical to the source pages;
  • every product has an image, and every recipe links only to products that exist;
  • every store has coordinates, and all 17 statutory documents are published;
  • every URL in the original sitemap is rebuilt or redirected, and every redirect lands on a real page.

4. Test every old URL against the build

The redirect map is only as good as its test. An end-to-end test requests every legacy URL against the production build and expects a 200 after following redirects:

import { test, expect } from "@playwright/test";
import legacy from "./fixtures/legacy-sitemap.json"; // every URL from the old sitemap

for (const path of legacy) {
  test(`legacy URL resolves: ${path}`, async ({ request }) => {
    const res = await request.get(path, { maxRedirects: 5 });
    expect(res.status(), path).toBe(200);
  });
}

Run it in CI. When someone later renames a page, the test fails before the change ships.

5. Measure performance before and after

A faster site helps users and rankings; a slower one undoes the good work. Single Lighthouse runs vary too much to make decisions with, so I pin the measurement:

  • the same Lighthouse and Chrome versions for every run;
  • the Lighthouse mobile throttling preset;
  • five runs per page, comparing medians, with builds measured interleaved;
  • a rule agreed before measuring, such as “ship only if FCP and LCP both improve”.

That rule mattered on Eastern. Inlining all CSS halved first contentful paint on every page, which looks like a clear win. But largest contentful paint got worse on five of six pages: without a render-blocking stylesheet, fonts and below-the-fold images started downloading early and competed with the hero image for bandwidth. It didn’t ship.

6. Launch and monitor

  • Deploy with redirects live from the first minute.
  • Submit the new sitemap in Google Search Console.
  • Watch coverage and “not found” reports over the following weeks, and fix any URL that was missed.
  • Keep the redirect file for the long term; inbound links to old URLs never fully stop.

Migration checklist

  • Inventory every URL (sitemap + crawl) and every content type and asset.
  • Decide keep or redirect for each URL; redirect to the most relevant real page.
  • Match the old trailing-slash and casing conventions.
  • Move content as reviewed, structured data; render pages from it.
  • Unit-test content integrity; end-to-end test every legacy URL.
  • Emit real 301s from the host, with a fallback.
  • Measure performance with pinned tooling and medians; agree the ship rule first.
  • Launch, submit the sitemap and monitor coverage.

References

  1. Google Search Central: site moves with URL changes developers.google.com
  2. Google Search Central: redirects and Google Search developers.google.com
  3. Cloudflare Pages: redirects developers.cloudflare.com
  4. Astro: redirects docs.astro.build

Working on something like this?

If this article maps to a problem in your own product, send me a short note about it. I'm happy to give a second opinion.