How to update your Ghost blog?

Why No One Talks About Update Ghost Blog Versions Anymore?

How to update your Ghost blog?
Photo by Andrew Neel / Unsplash

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).

(Update: Images are missing in this post due to a technical issue, read on the Medium for the complete article)

Ghost Hompage

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.

Moreover, I also want to import some of my articles on other platforms such as Hashnode, Medium and Tealfeed.

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).

Ghost CLI

Ghost CLI

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

This no longer works because I've updated both the ghost-cli and NodeJS. I try playing around with NPM, yet nothing makes sense.

Update Issue

As I'm using the old Recovery Console from Digital Ocean, I don't understand what's happening as I can't scroll up and down. I, therefore, try to connect to the server via SSH.

https://stackoverflow.com/questions/61063503/digital-ocean-droplet-restart-recovery-mode

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:

Nevertheless, I soon realise that I have to manually move the images, which still require SSH connection if I use SCP or FileZilla.

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.

One solution I find early on StackOverflow (where else?), is the use of curl to concatenate the ssh keys to the authorized_keys file on the server once I'm inside.

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.

It works.

I can finally access my site via VPS.

The Errors

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

As usual, I use the handy Digital Ocean's 1 Click installer on the Marketplace. There's now a Get Started option that explains the next steps for completing the setup.

Get Started Side menu

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 import my content from the exported file. Everything looks good except for the images which are missing as the file that you export only contains text in JSON format.

As I don't use a third-party server for hosting my images such as Digital Ocean Spaces or simply AWS, my images are stored on the server itself.

Using FileZilla, I connect to my previous VPS. I copy and paste the images on my local machine before connecting to the new server and uploading the images.

I refresh and it's working again.

All this time, my blog is down.

Conclusion

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.


If you want any help with setting up your blog, writing content or with programming in general, contact me.

You can also subscribe if you want to receive content. No spam for sure 🙂