Hosting a Ghost blog on Heroku
You may have noticed my blog is running Ghost, one of the best blog platforms in the world. However, one of its downsides is that, not being a PHP app, it's somewhat difficult to find a free place to host it.
There are three main hosting options for Ghost: you can either use Ghost's own hosting, use a DigitalOcean droplet or use Heroku. For this article, I decided to go with the cheapest option: Heroku.
Deploying Ghost to Heroku is very simple: Just click the button above, fill in the name and URL and click Deploy. Here's a quick GIF to illustrate the process:
Configuring your blog
After your app finishes its first deploy (should take around two minutes), you'll be redirected to your blog's admin, where you'll be guided on the rest of the setup (naming the blog and creating an admin user). At this point, we already have our blog up and running, but with a limitation: we're using a
herokuapp.com subdomain. Let's see how we can fix it.
Heroku offers free custom domains once you verify your account. This means that if you add a credit card to your heroku account, you'll be able to configure a custom domain for your blog. Fortunately, the entire process is free and you won't be billed, but you'll have to take care of what you do from now on.
Anyways, access your blog from your Heroku dashboard and go to the settings tab. If you scroll down, you'll find a section called Domains and Certificates, where you can add a custom domain. After pointing your DNS to Heroku, you'll also have to update your
PUBLIC_URL variable. To do this, scroll back up and click on the Reveal Config Vars button, then find the
PUBLIC_URL variable and change it to point to your new domain. After you've done this, restart all your dynos. Here's another GIF:
Keeping your dyno up
In the Heroku free plan, dynos (the programs that serve your blog) are disabled when there are no requests to your blog, and enabled again on new requests. A commonly known hack around this would be to use some uptime checker service that pings your site every 10 minutes to keep it up.
Before using this approach, check if Ghost's official hosting or DigitalOcean works better for you. After all, every setup is different.