Migrate Your WordPress Site to Raw Code
There is a fundamental difference between having a website and owning your website’s code. If you are on WordPress, you probably have the first but not the second.
Your WordPress site is a collection of database rows, PHP functions, plugin configurations, and theme files that are deeply intertwined with the WordPress runtime. You cannot take those files, drop them on a different server, and have a working website. You need WordPress installed. You need PHP. You need MySQL. You need the exact right versions of your plugins. The site is not portable — it is trapped inside an ecosystem.
Owning your code means having a directory of human-readable files that any developer, any hosting platform, and any AI tool can understand and work with. That is what this guide is about: getting from WordPress to code you truly own.
What code ownership actually looks like
A code-based website is a project directory. Here is a typical structure:
my-site/
src/
pages/ # Each page is a file (about.astro, services.astro)
content/
blog/ # Blog posts as markdown files
pages/ # Page content as markdown
components/ # Reusable pieces (Header, Footer, Card)
layouts/ # Page templates (BaseLayout, BlogLayout)
styles/ # CSS files
public/
images/ # Your images, in your repo
fonts/ # Your fonts
astro.config.mjs # Build configuration
package.json # Dependencies (typically 5-10, not 47 plugins)
Every file is plain text. You can open any of them in a text editor and read them. There are no database queries to understand, no PHP hooks to trace, no plugin interactions to debug. The entire site is visible and comprehensible in a way that a WordPress installation never is.
Portability
This is the killer advantage. A code-based site can be deployed to Cloudflare Pages, Vercel, Netlify, AWS S3, a Raspberry Pi in your closet, or any web server that can serve files. If your hosting provider doubles their prices tomorrow, you git push to a different provider and your site is live in minutes.
Try that with WordPress. Migrating a WordPress site between hosts means exporting the database, importing it on the new host, updating wp-config.php with new database credentials, fixing serialized data in the database, re-checking plugin compatibility with the new PHP version, and hoping nothing breaks. It takes hours on a good day.
Version control
Every change to a code-based site is tracked in Git. You can see who changed what, when, and why. You can compare any two versions of any file. You can revert a bad change with a single command. You have a complete, permanent history of every edit ever made to your website.
WordPress has page revisions — a partial, unreliable version history for post content only. Theme changes, plugin configurations, widget settings, menu updates, custom CSS: none of these are versioned. If a plugin update breaks your site, your only option is to restore a full database backup (if you have one) and lose everything that changed since the backup was taken.
AI editability
This is increasingly the most practical reason to own your code. AI coding agents — Claude Code, Cursor, Windsurf, Cline — work with files in a repository. They can read your components, understand your site structure, make targeted edits, run builds to verify their changes, and submit pull requests.
These tools cannot navigate wp-admin. They cannot configure a WordPress plugin. They cannot debug a PHP fatal error caused by a plugin conflict. The WordPress admin interface is a visual application designed for humans clicking through menus — it is opaque to AI.
When your site is code in a repository, an AI agent can do things like: “Update the pricing table on the services page,” “Add a new blog post from this Google Doc,” “Change the header background color to match our new brand guidelines,” or “Add structured data markup to all blog posts.” These are natural-language instructions that produce verified code changes.
The practical case for code ownership
Reduced ongoing costs
WordPress hosting runs $25-$300/month for managed hosting (WP Engine, Kinsta, Flywheel). Add maintenance — updates, security patches, backups, uptime monitoring — and you are looking at $1,500-$4,000/year for a small business site.
A code-based static site hosted on Cloudflare Pages, Vercel, or Netlify costs $0/month on free tiers that are generous enough for most sites. Cloudflare Pages, for example, offers unlimited bandwidth and 500 deploys per month at no cost. Your annual hosting cost drops to effectively zero.
Eliminated security maintenance
The WordPress ecosystem saw 7,966 new vulnerabilities in 2024 — about 22 per day. The vast majority (96%) are in plugins, and 43% require zero authentication to exploit. Keeping a WordPress site secure means constantly updating core, themes, and plugins, monitoring for vulnerabilities, and hoping that the window between vulnerability disclosure and your patch application is not exploited.
A static site has no server-side code running in production. No PHP interpreter, no database connection, no admin login page. The attack surface is zero. You do not need Wordfence, Sucuri, or any security plugin because there is nothing to secure.
Simplified deployment
WordPress deployment is often FTP-based or managed through hosting provider dashboards. Staging environments, when they exist, are clumsy copies of the production database. There is no reliable way to test changes without risking the live site.
Code-based sites deploy with git push. Push to a branch and get an automatic preview deployment. Push to main and the production site updates in 30-60 seconds. Every deployment is atomic — it either succeeds completely or fails without affecting the live site.
How to migrate: your options
1. AI coding agents (most popular approach — hours to days)
AI coding agents are the most common way people migrate from WordPress to code today. Tools like Claude Code, Cursor, Windsurf, and Cline can handle the entire process.
The workflow:
-
Extract content from WordPress. You have several options: the built-in XML export (Tools > Export in wp-admin), the WordPress REST API (most sites have this enabled at
/wp-json/wp/v2/), or database access if you have it. The AI agent can write extraction scripts for any of these. -
Scaffold the project. Tell the agent which framework you want (Astro is the most common choice for content sites, but Hugo, 11ty, and others all work). The agent creates the project structure, installs dependencies, and sets up configuration.
-
Convert content. The agent converts WordPress posts and pages to markdown files with proper frontmatter. It handles Gutenberg block markup, strips unnecessary WordPress HTML, and preserves metadata like dates, categories, tags, and featured images.
-
Recreate the design. Point the agent at your live WordPress site or screenshots. It can inspect the HTML/CSS and rebuild your layouts as components in your chosen framework.
-
Handle images. The agent downloads images from your WordPress uploads directory, saves them to your project, and updates all references in content files.
-
Set up deployment. Configure deployment to your preferred host — a few lines of config for Cloudflare Pages, Vercel, or Netlify.
Real-world examples:
- cursor.com migrated from Sanity CMS to code + Markdown in 3 days for $260 in AI tokens. They had been spending $56,848/year in CDN costs with their CMS setup. (Source)
- Sid Bharath migrated his WordPress blog to code in 3 hours using Claude Code. PageSpeed went from 67 to 100, hosting from $20/month to $0. (Source)
- Prefect.io rebuilt their CMS-based website as code in 1 week instead of the estimated 6 weeks. New landing pages now ship in 30 minutes instead of 2 weeks. (Source)
Cost: $20/month subscription + $10-50 in API tokens for a typical blog. Complex sites with many pages may cost more in tokens.
2. AI app builders (for non-developers — hours)
If you are not a developer and do not want to work with a terminal, tools like Bolt.new, v0.dev, Lovable, and Replit Agent can generate a website from screenshots and descriptions.
Take screenshots of your WordPress pages, paste them in, and describe what you want. The tool generates a complete project that you can deploy. The code quality varies and you may need several rounds of iteration, but these tools produce surprisingly capable results for marketing sites and portfolios.
The main trade-off is control. You get a working site, but you may not fully understand the generated code — which somewhat undermines the ownership goal. That said, the code is still yours in a repository, which is better than being locked into WordPress.
3. Hire a developer or agency (hands-off — days to weeks)
Many businesses choose to hire someone for the migration. Freelancers on Upwork and Toptal typically charge $500-$5,000 for a simple WordPress-to-static migration. Agencies charge $5,000-$25,000 for complex sites.
AI tools have made developers faster at this work. A migration that would have taken a developer 3-4 weeks in 2023 now takes days with AI assistance. This has made professional migrations more affordable than they used to be, though you are still paying for expertise and quality assurance.
4. Automated migration tools
Tools like BrowserCat Migrate automate the end-to-end process — paste a URL, get a deployed site with source code in a GitHub repository. Other tools focus on specific parts of the pipeline (content extraction, format conversion, deployment).
5. WordPress export tools
These handle content extraction specifically:
- WordPress XML Export (built-in): Tools > Export in wp-admin. Exports posts, pages, comments, and metadata as XML.
- WordPress REST API: Programmatic access to all content. More flexible than XML, especially for custom post types and ACF fields.
- wordpress-export-to-markdown: Converts XML export to markdown files with frontmatter and image downloads.
- wp2md: Another WordPress-to-markdown converter.
- Simply Static / WP2Static: WordPress plugins that export the rendered site as static HTML. Useful as a reference snapshot but not a maintainable codebase.
6. Manual migration (full control — weeks)
Build everything from scratch yourself. Export content, choose a framework, create the project, convert every file manually, rebuild every layout, download every image. This takes 2-6 weeks for a typical site but gives you intimate knowledge of every line of code.
WordPress-specific migration gotchas
Gutenberg blocks
WordPress’s block editor stores content as HTML with embedded comment markers. A simple paragraph looks like <!-- wp:paragraph --><p>Text</p><!-- /wp:paragraph -->. Simple blocks convert to markdown cleanly. Complex blocks — columns, galleries, tables, custom blocks from plugins like Kadence or GenerateBlocks — need individual handling. Expect to spend time on this if your site uses the block editor extensively.
Shortcodes
Older WordPress sites and some plugins use shortcodes like [contact-form-7 id="123"] or [gallery ids="1,2,3"]. These are WordPress-specific and will not render in markdown. You need to find each shortcode, understand what it does, and replace it with actual HTML or a framework component.
SEO metadata
Yoast SEO and RankMath store their metadata in the wp_postmeta table, not in the post content. A standard XML export includes some of this data, but not all. If you have custom meta titles, descriptions, canonical URLs, or Open Graph images set through your SEO plugin, you need to extract these separately (the REST API with the Yoast/RankMath REST extension is the most reliable method) and add them to your markdown frontmatter.
Custom post types and taxonomies
If your site has custom post types (Portfolio, Testimonials, Team, Services) or custom taxonomies, these need to become separate content collections in your new site. The WordPress REST API exposes custom post types at /wp-json/wp/v2/{post-type} if they are registered with show_in_rest.
wp-content/uploads structure
WordPress organizes uploads by year and month (/wp-content/uploads/2024/03/image.jpg). Many migration tools preserve this structure, but you probably want to reorganize images into a flatter structure. Whichever approach you take, make sure all image references in your content files are updated to match.
Choosing a framework
When you migrate to code, you need to choose a static site generator or framework. For most WordPress sites (blogs, marketing pages, business sites), the best options are:
- Astro: Built specifically for content sites. Zero JavaScript by default. Built-in content collections with validation. The most natural replacement for a content-focused WordPress site.
- Hugo: Extremely fast builds (milliseconds, not seconds). Written in Go. Good if you want the fastest possible build times and don’t mind Go templates.
- 11ty (Eleventy): Minimal and flexible. Uses familiar template languages (Nunjucks, Liquid). Good if you want maximum control with minimal framework overhead.
- Next.js: Overkill for most content sites, but the right choice if you need server-side logic, authentication, or app-like features.
All of these produce a directory of files you own. The choice of framework does not affect the ownership argument — it affects developer experience, build times, and available features.
Life after WordPress
The biggest adjustment is not technical — it is cultural. There is no wp-admin to log into. There is no “Publish” button. Content editing means opening a text file, making changes, and committing to Git.
For developers and technical teams, this is strictly better. Markdown is faster to write than the WordPress editor. Git gives you version history, branching, and collaboration tools that WordPress does not have. Deployment is instant and automatic.
For non-technical teams, you have options. Headless CMS tools like Decap CMS, Tina CMS, and Sanity provide visual editing interfaces backed by your Git repository. Your content team gets a familiar editing experience; your code stays as files in a repository. The cost for these tools ranges from free (Decap) to $15-99/month (Sanity, Contentful).
When to stay on WordPress
Code ownership is not universally the right move. WordPress is the better choice when:
- Your content team publishes frequently and needs a polished visual editor with preview, scheduling, and role-based access — and you do not want to set up a headless CMS
- Your site has active WooCommerce stores with inventory management, payment processing, and order fulfillment
- You rely on specific WordPress plugins (membership plugins, LMS platforms, booking systems) with functionality that would be expensive to replicate
- Your business does not have access to anyone technical enough to maintain a code-based site (though AI tools are rapidly lowering this bar)
WordPress is a powerful, mature platform with a vast ecosystem. The case for code ownership is strong, but it is not absolute. Migrate because the benefits justify the effort for your specific situation, not because someone on the internet told you WordPress is bad.
Automate Everything.
Tired of managing a fleet of fickle browsers? Sick of skipping e2e tests and paying the piper later?
Sign up now for free access to our headless browser fleet…