The Wild

WordPress to Next.js Migration: SEO-Safe Plan

· 7 min read · Mammals

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Migrating from WordPress to Next.js can improve performance and developer experience, but a careless move can tank your search rankings. This guide walks you through a step-by-step plan to migrate without losing SEO—covering URL preservation, content mapping, redirects, and ongoing monitoring.

What You'll Need

  • Access to your WordPress admin and hosting (to export content and set redirects)
  • A Next.js project set up (or a new one created)
  • Access to your domain's DNS settings (to switch the live site)
  • Google Search Console and Bing Webmaster Tools accounts (to monitor indexing)
  • A crawler tool like Screaming Frog or a simple sitemap generator (to audit URLs before and after)
  • Basic familiarity with Next.js routing and server-side rendering (SSR) or static generation (SSG)

Step-by-Step

  1. Audit your current WordPress URLs and structure. Use a crawler to export a complete list of all your existing URLs—pages, posts, categories, tags, images, and any custom post types. Note the exact URL patterns (e.g., /blog/post-name/ or /?p=123). This list is your source of truth.
  2. Map every old URL to a new Next.js route. Decide whether you'll keep the same URL structure or adopt a new one. Ideally, keep it identical to avoid redirects. If you must change, create a mapping spreadsheet: old URL → new URL. Include all pages, posts, and media files.
  3. Export your content from WordPress. Use the built-in WordPress exporter (Tools → Export) to get an XML file. Alternatively, use plugins like WP All Export or a custom script to pull content and metadata (title, meta description, featured images, custom fields). Store this data in a structured format (JSON or Markdown) for import into Next.js.
  4. Build your Next.js pages and components. Create dynamic routes for your posts and pages using Next.js file-based routing (e.g., pages/blog/[slug].js for posts). Use getStaticProps or getServerSideProps to fetch content from your exported data or a headless CMS if you're switching to one. Ensure your templates output the same HTML structure for headings, images, and internal links.
  5. Preserve all meta tags and structured data. In your Next.js Head component, include the exact title, meta description, canonical URL, and Open Graph tags from WordPress. If you used schema.org JSON-LD (e.g., Article, BreadcrumbList), replicate it exactly. This prevents loss of rich snippets.
  6. Set up 301 redirects for every changed URL. If any URL changes, create a next.config.js redirects array or use a custom _middleware.js to issue 301 (permanent) redirects from old URLs to new ones. For a large site, use a redirect map file. Test each redirect to ensure it points to the correct new page, not a 404.
  7. Recreate your XML sitemap and robots.txt. In Next.js, generate a dynamic sitemap.xml at /sitemap.xml that lists all your new URLs. Update robots.txt to point to the new sitemap and keep any disallow rules you had. Submit the new sitemap in Google Search Console and Bing Webmaster Tools.
  8. Migrate your domain and hosting. When ready, switch your domain's DNS to point to your Next.js hosting (e.g., Vercel, Netlify, or your own server). Ensure SSL certificates are configured. If you're using a subdomain or a staging site, test thoroughly before the final switch.
  9. Monitor for 404s and crawl errors. After going live, use a crawler to check for broken links. In Google Search Console, monitor the “Coverage” report for 404s. Fix any missing redirects or broken internal links immediately.
  10. Track rankings and traffic post-migration. Compare your search performance before and after. Use Search Console to see impressions, clicks, and average position. Expect a temporary dip for a few weeks, but if rankings drop sharply and don't recover, investigate redirects, page speed, or content differences.

Common Mistakes

  • Not preserving URL slugs exactly. Even a trailing slash change can cause a redirect, and if you forget one, you get a 404.
  • Forgetting to redirect old URLs that no longer exist. If you delete a page, redirect it to a relevant page or your homepage.
  • Ignoring image URLs. If your images move to a different path (e.g., from /wp-content/uploads/ to /images/), set up redirects for those too, or update all image references in content.
  • Using client-side rendering for all pages. If you use useEffect to fetch data on the client, search engines may not see the content. Use SSR or SSG for SEO-critical pages.
  • Missing meta robots tags. Ensure you don’t accidentally add noindex to pages that should be indexed.
  • Not testing redirects before going live. A broken redirect chain can cause crawl errors and wasted crawl budget.

Tips

  • Keep the same URL structure if at all possible. It’s the easiest way to avoid redirects and preserve link equity.
  • Use a staging environment to test everything. Run a full crawl on the staging site to compare URLs and content with the live WordPress site.
  • Implement redirects at the server level if possible. In Next.js, the next.config.js redirects are efficient, but for high-traffic sites, consider setting redirects in your hosting platform’s edge config.
  • Keep a backup of your WordPress site. You might need to roll back if something goes wrong.
  • Use a plugin like Redirection in WordPress to log 404s before migration. This gives you a list of URLs that need extra attention.
  • Monitor your server logs for 404s after migration. Look for patterns and fix them quickly.

Troubleshooting

What if rankings drop significantly after migration? First, check for 404 errors in Search Console. Fix any broken redirects. Then compare your new pages’ meta tags and content with the old ones—maybe you accidentally removed a keyword or a schema. Also check page speed; Next.js is usually faster, but if you’re using too much client-side JavaScript, it might be slower.

What if Google reindexes but shows “Crawled – currently not indexed”? This often happens with low-quality or thin content. Ensure your pages have substantial content, proper internal links, and that you’re not blocking Google with noindex or robots.txt.

What if my redirects are not working? Test a few URLs manually. Check the next.config.js syntax and ensure you’re using permanent: true for 301s. Also ensure the redirects are defined before any catch-all routes.

What if my sitemap is not being picked up? Submit the sitemap URL directly in Search Console. Verify that your sitemap.xml returns a valid XML response and that the URLs are accessible to Googlebot (not blocked by login or IP restrictions).

What if my images are not showing in search results? Ensure your images are in the same domain and are accessible. Add descriptive alt text and use proper image dimensions. If you changed image URLs, set up redirects or update the image references in your content.

What if I see a sudden increase in 404s after a few weeks? This could be due to external links pointing to old URLs that weren’t redirected. Use a tool like Google Search Console’s “Links” report to find top linked pages and ensure they have redirects.

Frequently Asked Questions

Do I need to keep the same URL structure?

It’s highly recommended. If you change URLs, you must set up 301 redirects, and even then, you may lose some link equity. Keeping the same structure minimizes risk.

Can I use a headless CMS instead of exporting content?

Yes, you can use a headless CMS like Contentful or Sanity, but you’ll still need to migrate your content and set up redirects. The process is similar—just ensure your new CMS outputs the same URLs or redirects.

How long does it take for Google to reindex the new site?

It varies from days to weeks. Submitting a sitemap and using internal links helps speed it up. Expect a temporary fluctuation in rankings during the transition.

Will I lose my search rankings if I migrate?

Not if you do it correctly. With proper redirects and content preservation, most sites recover within a few weeks. However, there’s always a small risk, so monitor closely.

Should I migrate all at once or incrementally?

For a small site, all at once is fine. For large sites, consider migrating section by section, but ensure redirects are in place for each section before moving to the next.

What should I do with old WordPress pages that have no equivalent in Next.js?

Redirect them to the closest relevant page (like the homepage or a category page) with a 301. If the page is truly obsolete, a 410 Gone status is also acceptable, but 301 is better for preserving SEO.