Recently i changed my old blog theme with a new one. The WordPress migration was not as easy as i thought. That is why i would like share my journey how to migrate a production website to theme.
You could also use the same way to upgrade your WordPress Website from an old state to newest one. If you are upgrading a couple version of WordPress Version, than you should be careful about all the dependencies and plugins to word properly. That’s why doing it on a staging/development environment and testing it is the most secure way.
If you have a big website, such as Woocommerce or with big live Traffic you should be aware, that you will have migration gap in your data, because we make the changes on a different environment.
First Backup the current state
Do not be brave and blindly just migrate the website. Always backup your website before executing a change or update. Your current hosting company could have an interval backup. Last time when i requested from my hosting company the latest backup of my WordPress Website they provided me the backup of one day before. That is a nice new to hear, but all the emojis of the blog posts were broken. So think always about encoding standarts.
That is why making a backup manually is the best option. I’m using the Duplicator to backup my blog. About the backup process i already wrote an article, check it out: How to migrate WordPress Website with Duplicator
Create a Staging Subdomain
Let your production website calmly work. Make the changes on your staging subdomain. I created therefor a new subdomain on the same server. “staging.azizozbek.ch”
I installed the last Backup of my blog, which i created with Duplicator. There multiple ways to copy a WordPress Website to another domain. If your hosting panel supports an internal tool, you can also try it out. For example with following tutorial of Plesk, you can clone your current state of your WordPress website to another: Cloning a WordPress Website
To use the duplicator way, you have to create a database for the subdomain. Be aware that you are gonna use this database for the new production domain. I created a database with the name of “20240723prod”.
Install the new Theme or make your changes
Now you can make your changes. Upgrade the WordPress Version and test it. Upgrade the plugins step by step and test it carefully everything. Be sure to deactivate all your caching plugins. If you are using Cloudflare make sure that you are in the “Development Mode“
If you are installing a new Theme. First install the theme. Then you will probably have to install the plugin dependencies. First carefully deactivate and delete the old theme relevant plugins. So you don’t have pages of plugins after you install the new theme plugins.
I used the Elementor Editor for my old blog. Now i’m using the native block feature of the WordPress. Because of this change, i had to check every blog post one by one if i used a elementor feature, which is not supported by block feature. If you are keeping the same editor such as Elementor, you can skip this step. After all you can switch to blocks with following official WordPress tutorial: Convert from the Classic to the Block Editor
The less plugin the better
Don’t use fancy plugins. The more plugins you have, the more careful you have to be with your website in terms of security and performance.
It’s time to deploy
After you are done with your changes, it’s time to take all to the real domain. As i mentioned in the beginning of the tutorial you have to manually fill the migration gap. If an image is missing, be sure to upload this image on the WordPress Dashboard. Copy/Pasting the image into file directory won’t help. WordPress saves the file informations into databases.
Since real domain and subdomain on the same hosting. I only changed the “docroot” of my domain.
My subdomain had following docroot: “/staging.azizozbek.ch” and my real domain “httpdocs”. I renamed the current “httpdocs” to “oldhttpdocs” and the directory of “staging.azizozbek.ch” to “httpdocs”
old directory name | new name |
---|---|
/httpdocs => | /httpdocs_old |
/staging.azizozbek.ch => | /httpdocs |
It is the same principle like you would use the “Symlink” in linux. With this method you don’t touch you old WordPress Website. Incase there is an error, you can just change the directory name, then everything is back.
Then of course the WP_HOME and WP_SITEURL in wp-config.php have to changed:
define('WP_HOME', 'https://azizozbek.ch');
define('WP_SITEURL', 'https://azizozbek.ch');
You can also change these in the database wp_options table.
Now we are using the new Database, which we created for the staging environment. The URL has to be updated. For this matter we can use following plugin: Better Search Replace
Update the urls and you can close the WordPress Migration. Just make sure everything works properly, if there is a big problem, rename the directory and use the old theme, till you fix the problem on the staging environment 🙂