How to update your Ghost blog?
Why No One Talks About Update Ghost Blog Versions Anymore?
In this post, I’ll share with you why and how I’m updating my blog to a new server containing the latest Ghost version (as of this writing).
Why update Ghost?
- ghost 2.9.x is out of support
- the theme feels old
- version 4.x has a lot of new features out of the box
- better integration with third-party services
I’m missing out.
My main focus since its inception is to write a quality blog post every week without putting much emphasis on themes or monetisation. My goal is about showing my work and share what I learn so that this can help people all around the globe.
Therefore, my focus remains on writing content instead of looking to optimise my blog. In fact, when I initially created the blog, I used Digital Ocean 1 click solution to install it. I only wanted to test if it could be an improvement over Medium. I didn’t even buy a domain name.
As a result, I left the default site URL config as the server’s IP Address. However, when you do that and click certain places on your website e.g. site address, it points to the IP Address. This happens even after I bought and redirected my domain name from Namecheap to my VPS.
So this particular update is long coming.
To do that, I’m experimenting with a quick and dirty solution using Python. At this point, the script is mostly complete except for replacing the images. There’s however a Node Utility that can be used (I’ve not tested yet though).
To correct the URL config issue, I run the command `ghost set URL config`. Nevertheless, I get the error that ghost-cli tool is out of date. Without thinking much into that — which turns out to be a big mistake — I update it.
Unfortunately, everything breaks.
I’ve forgotten that I have a 2.9.x version on my machine. From the tutorial I’m following, I assume I have the 3.x version.
To update it, I also have to update my current Node version.
Once done, I type the command to update Ghost to its latest major version before updating it to the 4th one.
The command is
ghost update 2
I promptly create a new key on my laptop and add it to the settings. However, I still can’t connect to the console. I then remember that only a newly created VPS will contain these keys by default. For the existing ones, I need to manually add them.
This is a struggle as the copy and paste feature does not work — irrespective of using VI or Nano. I try looking for solutions on this subject. This is actually a well-known bug that has not been resolved for years. Most probably because they have released newer versions with the latest VPS.
I’m ready to give up and try other solutions such as:
- create a new WordPress blog via the one-click installer
- use the built-in importer
- change the domain name to point on this new server
scp -r ghost-mgr@server_ip_address:/var/www/ghost/content/images ghost-images
Since reading the bestselling book Grit, I now find it natural to try again the next day instead of thinking about giving up. Plus, during the weekend, I can only focus on one problem at a time.
Therefore, I try this method by creating a file on Dropbox containing my keys but they aren’t added. I glance into the file content on the recovery console to why it wasn’t working.
Turns out, a blank line is missing between the existing keys. Once I add it and save the file, it’s finally time for the big event.
I can finally access my site via VPS.
I can now clearly see that the NodeJS version is not compatible with the Ghost-CLI tool. I try correcting the course by installing Node Version Manager (NVM) and switching to the corresponding versions to:
- update ghost 2 to the latest version
- then update it to version 4
However, there seems to be a dependency error each time I switch versions.
Thinking about another solution, meanwhile, I try creating a new VPS with the aim of importing all my content to the new server.
A new Server
I perform this process several times because I’m not sure which options to take, how to add the domain name and if SSL is needed?
As a Software Developer, I’m usually in a hurry to do things without first reading the docs, especially in the section above. So I follow the steps one at a time until everything looks good.
The initial time you enter your server via SSH, Ghost CLI runs a script asking you default values such as your domain name and if you want to install SSL certificates.
Importing Content & Images
I refresh and it’s working again.
All this time, my blog is down.
I learned lots of new things throughout this challenging adventure. However, the most important part is to not give up, especially when you feel completely blocked.
Additionally, the best advice I can give to anyone reading this is to properly read the documentation step by step when doing tasks you are not comfortable with. This helps prevent lots of confusion and most importantly, headaches.