Migrating From WordPress to Next.js Without Losing SEO

How to move a site from WordPress to Next.js without losing search traffic: inventory, keeping URLs, redirects, metadata and schema, content and media, replacing built-in features, and testing.

Moving a site from WordPress to Next.js keeps its search traffic when the new site preserves every important URL or redirects it, carries over titles, descriptions, canonicals and structured data from WordPress’s SEO fields, renders all public pages on the server, and moves media without breaking image URLs. The two common routes are a headless setup, where WordPress stays as the CMS and Next.js renders the front end, and a full migration, where content moves to another CMS or files. The SEO work is similar in both; this guide covers it step by step.

Headless or full migration?

Headless WordPress + Next.js Full migration
Editors Keep using WordPress Learn a new CMS
Content move None; read through the API Export, convert and import
SEO plugin data Read from the API Must be exported and mapped
Risk Lower Higher

The headless setup is covered in headless WordPress with Next.js. The steps below apply to both.

Step 1: inventory everything

  1. Crawl the current site and export every URL with its status, title, meta description, canonical, H1 and word count.
  2. Export pages with clicks, impressions and backlinks from Search Console and your link tools.
  3. Export SEO plugin fields (such as Yoast’s title, description, canonical and noindex settings) through the REST API or a database export.
  4. List every redirect already configured in WordPress plugins or the server.

Step 2: keep URLs where possible

Match WordPress permalinks in Next.js routes, including trailing slashes (set trailingSlash: true in next.config.js if your WordPress URLs end with a slash). Keeping URLs identical removes most migration risk. Where URLs must change, map each old URL to its new one.

Step 3: redirects

// next.config.js
module.exports = {
  trailingSlash: true,
  async redirects() {
    const map = require("./redirects.json");   // [{ "source": "/old/", "destination": "/new/" }]
    return map.map((r) => ({ ...r, permanent: true }));
  },
};

Carry over existing WordPress redirects too, and handle old patterns such as /category/ and /tag/ archives, date archives and attachment pages, which WordPress often creates without you noticing. Redirect them to relevant pages or return 404 if they had no value.

Step 4: metadata and structured data

  • Map titles, descriptions and robots settings from the SEO fields into generateMetadata for each route.
  • Set canonicals to the new public URLs.
  • Rebuild structured data in server components from the same data; see automating structured data.

Step 5: content and media

  • Convert WordPress content (HTML or blocks) to your new format, checking headings, tables, embeds and shortcodes that will not render outside WordPress.
  • Keep image URLs working: either keep the /wp-content/uploads/ paths or redirect them to the new locations.
  • Fix internal links in content to point directly to final URLs.

Step 6: the pieces WordPress gave you for free

WordPress feature Next.js replacement
XML sitemap app/sitemap.js
robots.txt app/robots.js
RSS feed A route handler that outputs RSS
404 page not-found.js with a real 404 status
Search Your own search; see semantic site search
Forms and comments Form handlers or services; decide whether comments move

Step 7: test and launch

  1. Crawl staging and compare with the old crawl: missing URLs, changed titles, broken links.
  2. Run our SEO smoke test and AI crawler access checker.
  3. Test every redirect in the map.
  4. Launch, submit the new sitemap, and monitor Search Console daily for two weeks. See the migration checklist.

Frequently asked questions

Will moving to Next.js improve rankings?

Not by itself. It can improve speed and flexibility, but rankings depend on content and structure. A careless migration is more likely to lose traffic than gain it.

Do we need to keep WordPress running?

In a headless setup, yes. In a full migration, keep it available for reference until the new site is stable, but not publicly indexable.

How long does such a migration take?

From a few weeks for a small site to several months for large sites with many content types.

Sources

  1. Next.js documentation, redirects, trailingSlash, generateMetadata, sitemap and robots conventions
  2. Google Search Central, “Site moves with URL changes”
  3. WordPress REST API handbook