Skip to content

Changing your blog address on Ghost

Akash Senapaty
4 min read
Changing your blog address on Ghost

I've begun using the Ghost platform for blogging and I absolutely love the minimal interface and the editor. However, I set it up on a temporary URL and when it came time to change I struggled. I finally got it to work and here is my walkthrough - archived for when I need it again..

Disclaimer: I'm not a coder. I just enjoy this stuff. So there may always be better ways of doing things. These steps worked perfectly for me. If you use them, then use DigitalOcean snapshots to backup your data beforehand. I did that, and it saved me multiple times

Getting started with Ghost

Choice of platform

Here are the two options I considered when I decided I want to use the ghost platform.

  1. GhostPro - which is the official platform offered by Ghost. Starting at $19 p.month
  2. Host it on DigitalOcean - This is way cheaper at $6 p.month, so its great for personal blogs. If you're inclined to tinkering about a bit - then pick this option. Click here for a $200 credit, which you can use over 60 days

Hosting on DigitalOcean

The process is:

  1. Sign up with DigitalOcean
  2. Pick the one-click-install of Ghost
  3. Once the installer has completed, you need to access that droplet (IP address) to complete the setup
  4. For step-3 you need a terminal window. Max and Linux folks should be fine. For Windows users, you'll need the bash terminal. You can download it here. Install it and keep all the default options if you aren't sure
    bash
  5. Once set up you should be able to access the /ghost directory on your blog to complete setup via your browser. So if you set it up on newdomain.com then head over to newdomain.com/ghost to complete the setup. You're done!

Changing the address of your Ghost Blog

This is the main reason why I wrote this post. I wanted to migrate to this domain away from blog.akashsenapaty.com and I couldn't find any guide to do it. So here are the steps I followed:
Overview:
(1) Configured my blog to work with a second URL and then
(2) I implemented a 301 permanent redirect from the old domain to the new domain. It's a bit round about, but it works perfectly fine.

Tip - You can also use this exact same process to redirect all request to www.mydomain.com, to mydomain.com. I.e. remove the www from the URL

These steps worked fine for my on my DigitalOcean hosted blog. Also, you'll need to be on the terminal to run the following commands

  1. SSH into your Ghost Blog with the commmand: ssh [email protected] replacing for the IP address of your blog
    ssh-into-ghost
  2. Use sudo -i -u ghost-mgr so that you start managing your Ghost installation
  3. Use cd /var/www/ghost to change to the Ghost directory
  4. Now the fun starts. We tell Ghost to configure a new domain with the following command ghost config url https://newdomain.com - assuming that you're shifting to newdomain.com
  5. Next we tell Nginx to accept requests from newdomain.com. Run ghost setup nginx to execute this
  6. Next we need SSL certificates for for new domain. Run ghost setup ssl.
  7. And finally we tell Ghost to restart with ghost restart

Now, you'll have Ghost running and responding to requests both from olddomain.com and newdomain.com

So now we need to tell Nginx to redirect all requests from olddomain.com to newdomain.com - here are the steps I followed for that:

  1. SFTP into the IP address of your Ghost blog. I use Filezilla - download
  2. Navigate to /var/www/ghost/system/files
  3. Here you'll see .conf files for olddomain.com and newdomain.com ghost-dir
  4. We want to edit BOTH the .conf files for olddomain.com (ssl and non-ssl) and add in a 301 redirect - so download BOTH the .conf files for olddomain.com. Save a backup of this
  5. Open up the files in a text editor (Sublime text for instance)
  6. Open olddomain.conf and add the following line return 301 https://newdomain.com$request_uri; in the location block. This tells Nginx to permanently redirect requests made to olddomain.com, to newdomain.com instead.
    conf-file-1
  7. Open olddomain-ssl.conf and add the above line again into the location block.
    conf-file-2-ssl
  8. Reupload and replace the old files in the system directory
  9. Open the terminal and SSH into your Ghost droplet again
  10. Run sudo nginx -t to make sure that the new Nginx configuration haven't broken anything
  11. Run systemctl restart nginx restart Nginx and refresh the config files and you're done

Comments