How to move from WordPress to Next.js without losing rankings
Move from WordPress to Next.js: choose where content lives, keep URLs and trailing slashes, carry over SEO metadata, redirect the rest. Steps and config.
By Sohail Hussain19 November 20266 min read
To move from WordPress to Next.js without losing rankings, decide first where your content will live, then rebuild the templates in Next.js while keeping every URL identical where you can, including WordPress's trailing slash. Carry over each page's title, description and structured data, redirect the URLs that do change (archives, date-based posts, feeds), and watch Search Console closely for the first weeks. The front end changes completely; to Google, the site should look like the same pages, faster.
We build company sites with Next.js and move existing WordPress sites to it as part of our website redesign and migration service. Why we build company websites with Next.js explains the reasoning. This post is the practical side.
Should you move from WordPress to Next.js at all?
Good reasons: the site is slow despite tuning, security updates are a monthly worry, you need features WordPress makes awkward (a client portal, a calculator, an app-like interface), or a development team will maintain the site anyway.
Weak reasons: your marketing team builds new landing pages every week in a page builder, the site depends on plugins such as WooCommerce or an LMS that would each have to be rebuilt, or nobody will own the code after launch. In those cases a well-built WordPress site is the better answer. WordPress vs custom website walks through the decision.
Where will the content live after the move?
This is the first decision, because it shapes everything after it.
| Option | Editors work in | Suits | Watch out for |
|---|---|---|---|
| Headless WordPress | The WordPress admin they know | Teams that publish often and like WordPress | You still update and secure WordPress |
| Another headless CMS (Sanity, Payload, Contentful) | A new, cleaner editor | Structured content, several editors | Content export and a learning curve |
| Markdown or MDX files in the repository | A code editor or Git | Sites edited by developers | Non-technical editors cannot publish |
Headless WordPress with Next.js covers the first option in depth, and how to add a CMS to a Next.js site the second.
How do you get the content out of WordPress?
Step 1: Inventory content and plugins
List every content type: pages, posts, custom post types, categories, tags, authors. Then list every active plugin and what it does for visitors. SEO plugins write titles and schema, form plugins handle enquiries, redirect plugins hold old redirects, and cookie, search and analytics plugins each add something to the page. Every front-end feature becomes a task in the new build. Export the redirect plugin's rules now; they belong in the new redirect map.
Step 2: Choose where content will live
Use the table above. If editors are happy in WordPress and publish weekly, keep it headless. If content is mostly static pages edited a few times a year, files or a lighter CMS remove a server you would otherwise maintain.
Step 3: Export the content
The WordPress REST API returns posts as JSON, up to 100 per request. The response headers X-WP-Total and X-WP-TotalPages tell you how many pages to fetch:
curl -s "https://www.example.com/wp-json/wp/v2/posts?per_page=100&page=1&_embed" -o posts-1.json
Repeat for pages and for each custom post type that is exposed to the API. If you use Yoast SEO, each item includes a yoast_head_json field with its title, description, canonical and Open Graph data, which saves copying them by hand.
Step 4: Move the media
Image and PDF URLs under /wp-content/uploads/ collect links and image-search traffic too. The simplest way to keep them is to copy the uploads folder into the new site's public/wp-content/uploads/, so every file keeps its exact URL. For a large library, put the files in object storage and redirect /wp-content/uploads/ paths there instead.
How do you rebuild the site without changing its URLs?
Step 5: Rebuild templates and metadata
Build each template, then carry over metadata with generateMetadata in each route: title, description, canonical, Open Graph image, and the structured data the SEO plugin used to output. Check that every page has one H1 and the same heading as before, unless you are deliberately improving it.
Step 6: Keep URLs identical where possible
WordPress URLs end in a slash, such as /services/web-design/. Next.js removes trailing slashes by default with a permanent redirect, which would put a redirect in front of every page on your site. Set trailingSlash: true to keep the WordPress form, and use the same slugs. Most pages then need no redirect at all.
Step 7: Redirect what changes
These WordPress URLs are easy to forget:
- Category, tag and author archives:
/category/news/,/tag/seo/,/author/admin/. - Date-based post URLs, if permalinks ever included the date.
- Feeds:
/feed/and/category/news/feed/. - Pagination:
/page/2/,/category/news/page/3/. - Attachment pages and
?p=123short links.
With trailingSlash: true, write redirect sources with the trailing slash, because that is the form the old URLs had:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
trailingSlash: true,
async redirects() {
return [
{
source: "/:year(\\d{4})/:month(\\d{2})/:slug/",
destination: "/blog/:slug/",
permanent: true,
},
{
source: "/category/:slug/",
destination: "/blog/category/:slug/",
permanent: true,
},
];
},
};
export default nextConfig;
permanent: true sends a 308, which Google treats like a 301. As of October 2026, Vercel allows up to 1,024 redirects in this config, and the Next.js redirecting guide recommends Proxy (called Middleware before Next.js 16) for larger sets. Redirect mapping has the template for the full list, and the redirect generator writes the next.config.ts entries from it.
What breaks most often in a WordPress to Next.js move?
Four things catch teams out, usually in the last week before launch.
Shortcodes and page-builder markup. Content fetched through the REST API arrives as rendered HTML. Shortcodes from form, gallery or slider plugins come through as the markup the plugin generated, without the CSS and JavaScript it relied on. Search the exported content for them early and decide, one by one, whether each becomes a component or goes.
Forms. A form plugin handled validation, spam protection, email delivery and storage of submissions. In Next.js each of those is rebuilt, usually as a route handler or server action plus a transactional email service. Test delivery to the real inbox, not just the success message.
Site search. WordPress search at /?s= does not exist in the new site. Build a replacement or remove the search box. Nobody misses it on a ten-page site; everyone does on a blog with five hundred posts.
Hard-coded links inside content. Posts often contain absolute links to /wp-content/uploads/ files and old URL forms such as ?p=123. Keep the uploads paths working, as in step 4, and rewrite the other links during import, or each one becomes a redirect hop.
How do you launch the new site?
Step 8: Rebuild the sitemap and robots.txt
Next.js generates both from app/sitemap.ts and app/robots.ts. Compare the new sitemap's URL count with the old one; a large gap means pages were missed or archives dropped on purpose. Check the robots.txt with the robots.txt tester. Sitemaps and robots.txt in Next.js has the code.
Step 9: Launch and monitor
Switch the domain, then test redirects, submit the sitemap in Search Console and send a test enquiry through every form. Keep the old WordPress install running privately for a month so you can check anything that was missed. The week after a migration has the daily checklist, and the website redesign process puts this move in the context of the whole project.
Was this guide useful?