How to change the domain associated with a one-click installed Ghost blog on DigitalOcean

How to change the domain associated with a one-click installed Ghost blog on DigitalOcean

For those who don't know, Ghost is an open-source blogging platform, which in addition to powering this site, also is used behind many other sites on the web. DigitalOcean is a reliable and affordable hosting provider behind an exponentially larger number of even more sites.

Ghost is a marketplace application on DigitalOcean, meaning you can set up a server to host your site and install it with a click.

As some point in time in the future, you may want to update/change the domain name associated with your Ghost blog that you're hosting on DigitalOcean. There's only a few steps you need to do, so read on to learn how.

Update DNS

The first thing you need to do is update your DNS settings to point the domain you'll be switching to, to the IP address of your DigitalOcean instance that's been serving your Ghost blog.

Set up 301 redirects

You'll also need to set up 301 redirects. This is important because your old blog posts are most likely indexed on search engines. If you update your domain name without 301s, then those links will break and those pages will drop from indexes, meaning you'll need to start all over building up organic search traffic for your posts again. CloudFlare is a helpful DNS provider that makes setting up 301s fairly easy.

Update your Ghost site config

SSH into your DigitalOcean server, switch to and update your site config:

su ghost-mgr
cd /var/www/ghost
ghost config url https://new_domain_name

Replace new_domain_name with the domain name you are changing to, e.g. willbinns.org.

Update nginx for the new domain name

ghost setup nginx

Create an SSL certificate for the new domain name

ghost setup ssl

If you're using CloudFlare you'll need to make sure the proxy icon is grey before completing this step, otherwise, your server is going to encounter an issue when issuing the SSL. You can turn the proxy back on once the SSL issuance is completed.

Restart Ghost

ghost restart

And that's it! You've just changed the domain associated with your one-click installed Ghost blog that you've been hosting on DigitalOcean.

Acknowledgements

A special thanks is owed to Dan Rowden who wrote a quick five-step tutorial detailing how to update the URL of your self-hosted Ghost site.

I created the steps outlined above for this post and deviated from his slightly, because on DigitalOcean, you'll need to make sure you are the ghost-mgr user when running the ghost commands, otherwise you're going to see errors about running them as the root user.

Also, it's a good idea to set up 301 redirects before switching your domain so you don't lose your organic search traffic that you were getting from the previous domain you were using that's already indexed.