The Craft upgrade itself is one command. Everything around it is the project.
This autumn I upgraded a company website from Craft 4 to Craft 5. A mid-sized site: 108 fields, 16 sections, a dozen commercial plugins, a page builder made of Neo blocks with Matrix fields inside them, and a custom plugin that handles payments. Nothing exotic, which is exactly why the lessons apply to most Craft 4 sites still out there.
Here's what the upgrade actually involved, in the order it happened.
Why it couldn't wait
The site worked fine on Craft 4. The reason to move was security:
- Craft 4 pins Twig to the 3.19 line. The fixes for several Twig sandbox vulnerabilities, one of them critical, only exist from 3.26 on, and that version is only reachable on Craft 5.
- The project pinned Composer's platform PHP to 8.0, which froze the Symfony packages on a version line that no longer gets security fixes.
-
composer auditreported 31 advisories across 8 packages. None of them could be fixed within Craft 4's constraints.
When a site reaches the point where composer update can't fix a known vulnerability, staying put is no longer the safe option.
Step 1: Take inventory before touching anything
Before changing a single line, I listed every plugin, field and piece of custom code, and what Craft 5 would mean for each. The plugins fell into four groups:
| Group | What it means | Examples from this site |
|---|---|---|
| Same major on both | Works on Craft 4 and 5 — no jump | Freeform, NoCache |
| New major version | Bump the constraint, check the upgrade notes | Neo, CKEditor, Blitz, SEOmatic, Retour, Sprig |
| Not needed | Remove before the upgrade | Super Table (used by zero fields), an internal utility plugin, a minifier made redundant by Blitz |
| Abandoned | No Craft 5 version at all | A link field plugin (typedlinkfield) |
The field layer is where the risk lives. On this site that meant ten Matrix fields, two Neo fields, and six places where a Matrix field sat inside a Neo block — after the upgrade, Matrix blocks become entries, so that becomes entry → Neo block → nested entry. Craft 5 also moves to one global field namespace, which surfaced handle collisions: four fields called linkField, three called copy, two text, two image.
The Twig side, by contrast, was small: 61 templates, and only 13 lines that touched Matrix or Neo directly. A few needed fixing — a malformed eager-load, a nested query inside a loop — but templates were not the hard part.
Step 2: Ship the cleanup on Craft 4 first
Everything that could be done on Craft 4 went to production on Craft 4, as a separate release: removing Super Table and the unused plugins, deleting two orphaned fields, clearing out dead code. If something goes wrong there, rollback is an ordinary Craft 4 revert.
Two commands in that release turned out to be essential:
-
php craft neo/block-types/resave— guards against a known Neo pitfall where block content can be lost during the upgrade (Neo #943). Run it on Craft 4, before upgrading. -
php craft utils/fix-field-layout-uids— I only found this one during a local test run. Craft 5's content migration refused to run because field layout elements shared UIDs: the Neo block types had been created by copying each other, which left 26 duplicates. The fix command only exists on Craft 4.
And the order matters. craft up runs migrations before it applies project config. If the UID fix arrived together with the Craft 5 code, production's migration would fail on the same check. So the cleanup has to be live on Craft 4 before the Craft 5 release is deployed.
Step 3: The abandoned plugin decides the plan
The link field plugin had no Craft 5 version, and its composer.json required craftcms/cms: ^4.0.0. That means it can't even be installed next to Craft 5: it has to disappear in the same commit that bumps Craft. There's no automated migration from it to Craft's native Link field — third-party migrations are DIY.
What made it manageable:
-
composer remove, never uninstall in the control panel. The plugin kept its values in its own database table. Removing the package leaves the table in place; uninstalling in the CP would have dropped it, along with every link on the site. -
One native Link field replaced ten old ones. All ten behaved the same way, so a single multi-instance field (
hyperlink, becauselinkis a reserved handle) was enough. -
Keep the layout element UIDs and the old handles. In each of the ten field layouts, the old element was switched to the new field with its UID unchanged and its old handle as an override. Templates kept calling
block.buttonanditem.linkFieldas before. -
A content migration copied the old table into Craft 5's content storage under those UIDs — including drafts, revisions and trashed entries. It ran inside
craft up, needing neither the old plugin nor the new field to exist yet.
Because craft up and the older migrate/all + project-config/sync run things in a different order, I tested the full deploy both ways from the same database snapshot. Both migrated all 444 links, and every migrated value was checked against its original row.
One behaviour difference only showed up in that comparison: the old plugin output nothing for a link to a disabled entry, while Craft's native link returns its URL anyway. Every template now calls getUrl(false), which keeps the old behaviour. On this site, one live link on the home page would otherwise have pointed at a disabled page.
Step 4: Custom code finds old bugs
The custom payments plugin needed the usual Craft 5 changes:
- The sections service is gone:
getSections()→getEntries(). -
$entry->enabledForSite = …→setEnabledForSite(). - New entries need an entry type ID as well as a section ID.
-
$entry->sectionis null for nested entries. A global "after save" handler read$entry->section->handle— fine on Craft 4, a fatal error on Craft 5 the first time anyone saved a Matrix block. Now it'sgetSection()?->handle.
Porting it also uncovered bugs that had been there all along: a namespace case mismatch, a call that would have been fatal in one webhook branch, and a lookup that never matched anything, so a status update had silently never happened. An upgrade is a rare moment when someone reads every line of old custom code; it's worth fixing what turns up.
The payment webhooks were tested locally with signed test events for every case the plugin handles, before the code went anywhere near staging.
Step 5: Deploy like it can go wrong
Use craft up in the deploy. The host's post-deploy tasks ran migrate/all and then project-config/sync. Those became a single php craft up --interactive=0, which runs migrations and applies project config in the right order. It already works on Craft 4, so that change can go in before the upgrade.
Switch PHP at the last moment. On this host the PHP version applies to the next build, so it was raised from 8.1 to 8.3 right before the Craft 5 deploy — not earlier, not later.
Compare the whole site, not a few pages. On staging I crawled all 180 URLs before and after the upgrade and compared status codes, links, text, meta tags and images. They matched. That says more than an afternoon of clicking.
Watch out for migrations that succeed without doing anything. One intermediate commit had a bug: craft up would skip all 444 links but still record the migration as done — after which the fixed migration could never run. It never reached any environment, but it changed how I deploy: production gets exactly two known builds, in a fixed order, and nothing in between.
Expect environment surprises. Staging's database was a fresh copy of production, but some environment variables weren't — the form's reCAPTCHA keys were missing, so submissions failed. Nothing to do with Craft 5, and exactly the kind of thing that wastes an hour if you assume the upgrade broke it.
Step 6: Know your point of no return
Before craft up runs on production, rollback is simple: the previous build plus the database backup taken minutes earlier. After it, rollback is still possible — until editors start adding content. From that moment, rolling back means losing their work.
So the production cutover gets:
- a low-traffic window and a content freeze announced to editors;
- an on-demand database backup right before the deploy, with a downloaded copy;
- a rollback that's been rehearsed once on staging, so it's a known 15-minute procedure rather than an improvisation.
Where it stands
At the time of writing, the upgrade runs on staging and has passed the full comparison; the team is doing its own checks before the production cutover. I'll add how production went once it's done.
A checklist for your own Craft 4 → 5 upgrade
-
Run
composer audit. If it reports issues Craft 4 can't fix, the upgrade is a security task, not a nice-to-have. - Inventory plugins into: same major, new major, not needed, abandoned. The abandoned ones shape the plan.
-
Ship the cleanup on Craft 4 first, including
neo/block-types/resaveandutils/fix-field-layout-uidsif you use Neo. -
Remove abandoned plugins with
composer remove, not the control panel, so their data survives for the migration. - Test the deploy from a production snapshot, with the exact commands your host runs.
- Diff the whole site before and after, not just a handful of pages.
- Plan the point of no return: content freeze, fresh backup, rehearsed rollback.
The same habits will matter even more for the move to Craft 6: it can only be reached from the latest Craft 5, so a site still on Craft 4 has two upgrades ahead of it.
Quick answers
What should I do on Craft 4 before upgrading to Craft 5?
Clean up first and ship that as its own release: remove plugins you don't use, delete unused fields, and if you use Neo, run the two commands from step 2. A problem is much easier to undo while you're still on Craft 4.
How do I move links from Typed Link Field to Craft 5's Link field?
There's no ready-made tool. Remove the old plugin with composer remove so its data stays in the database, add a native Link field, and copy the old values over in a content migration. On this site that moved all 444 links.
Should I uninstall an abandoned plugin in the control panel?
Not if you still need its data. Uninstalling there can delete the plugin's database table. composer remove takes away the code and leaves the data alone.
Originally published on b10k.nl. I'm Bohdan, a freelance Craft CMS developer in the Netherlands. Planning the move to Craft 6? Start with a Craft 6 readiness check.
Top comments (0)