When I started this blog, I forgot to configure the www. prefix. Damn it! There were so many steps to meticulously follow to get the blog going, and I was a little afraid to do anything to modify the configuration.

When I wanted to go add the new domain, there were a few steps. It took scouring around the internet, but I eventually found how.

The same general rules apply to adding new domains (e.g. if you want to change the domain name of your blog).

These rules apply if you self-host using DigitalOcean. But it's not terribly easy, and involves editing your core site code. A much easier way to host your Ghost blog and manage it all is to let them do the heavy lifting for you. It's $29 a month and you get a ton of benefits, and zero random crashes and downtime.

Step 1: Point the domain at your new IP address

Do this with your domain admin. In my case, it was in Hover, but it would work with NameCheap, Godaddy, or one of the dozens of others.

I added one line, an A reference:

Adding a new domain to your Ghost blog - the A redirect.

Step 2: Modify your NGINX configuration

I use NGINX as a web server (for Ghost). For most out-of-the-box servers, NGINX is the default (I've never heard of someone using Apache with Ghost).

Go to /var/etc/sites-available. You need to modify two files:

  1. your-site.com.conf (non-SSL version)
  2. your-site.com-ssl.conf (SSL version)

In both of these, you need to add in the new domain or the www. prefix into the configuration. Open up one of the files:

sudo vim /var/etc/sites-available/your-site.net-ssl.conf

In it you'll find the server block (it's the only thing in the file, it's right up top), where you add the www prefix (added in the image below, right after 'hooshmand.net')

Then restart nginx.

To be honest — I'm not sure if it's necessary to restart Ghost, but I did it and it was painless.

sudo service nginx restart

Step 3: Create/add certificates for your new domains

After you've modified nginx, you need to add certificates for your new domain. You actually are going to add the www subdomain to the existing certificate.

To do this, you use certbot.

sudo certbot -d hooshmand.net -d www.hooshmand.net

Note that certbot is called letsencrypt on some installations.

Certbot will ask you some questions. The answers are:

  1. When it asks you something like 'There is an existing certificate. Do you want to add the new domain to the existing one?' you say 'yes'.
  2. When it asks you something like 'Do you want to redirect non-https traffic to https traffic?' also say you want to.

That's it!