Deploying a Ghost Blog to Heroku

ghost heroku

Picking a blogging platform can get really complicated when you start comparing all the different ones out there; Wordpress, Blogger, Ghost, Medium, Postach.io (what MonkeyHacks is powered by!), etc. One huge factor to consider is pricing. While Ghost plans start out at $8/month, you can actually host it yourself or on other third party hosts for free! One awesome host I use for various projects of mine is Heroku. Although Heroku is not officially supported by Ghost, you can in fact deploy Ghost on Heroku with a few easy steps

In this tutorial, I will demonstrate how to deploy Ghost to Heroku and add custom themes. This tutorial assumes you already have a Heroku account. If not, sign up here.

Deploying To Heroku

To deploy Ghost to Heroku, navigate to this Git Repository.

You will see the following button:

ghost deploy

Click the button to get redirected to Heroku where you will setup a new application for your Ghost blog. You should then see the following screen:

ghost on heroku

Config Variables and Amazon S3

Enter you application name and and be sure to also edit the HEROKU_URL variable with your chosen name. The next variables you can optionally fill out are regarding file storage. Heroku apps aren’t meant to store files. Every time your app gets deployed (i.e. your dyno is stopped and restarted), the files will be discarded. Because of this, a simple solution for uploading files through Ghost on Heroku is to use Amazon S3.

If you don’t already have an Amazon S3 account, I’d recommend setting one up here. Once created, login and navigate to the S3 Console.

We need to create a Bucket for where our files will get uploaded to. Click the Create Bucket and name it anything you want.

s3 create bucket

Next you will need to create an Access Key ID and Secret Access Key to continue filling out the Config Variables needed for your Heroku application. If you click on your user name in the upper right hand corner of the screen, you should see a drop down menu appear.

s3 dropdown

Click on Security Credentials. Once you are navigated to the Security Credentials page, look on the left hand side of the screen, and click users. Create a new user and generate a new policy for the user that looks like the following:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
         "s3:ListAllMyBuckets"
      ],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:ListBucketVersions",
        "s3:GetBucketLocation"
      ],
      "Resource": "arn:aws:s3:::[BUCKET_NAME]"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:GetObjectAcl",
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:DeleteObject"
      ],
      "Resource": "arn:aws:s3:::[BUCKET_NAME]/*"
    }
  ]
}

After you policy is created, click on the Security Credentials tab to generate an Access Key. You will need to make note of both the Access Key and Secret Access Key, as you will need those values for your Heroku config variables. Important: Store you Secret Access Key in a safe place, because you will not be able to access it from the S3 Console anymore.

You should now have all the necessary info to complete the Config Variables section of your new Heroku application. The variables you need to assign values to are the following:

Once you are finished, hit the big Deploy for Free button when finished. You should now be able to navigate to your new Heroku application and see your Ghost Blog live. In order to begin editing content, you will need to create an account. You can do so by navigating to https://[HEROKU-APP-NAME].herokupp.com/ghost.

Custom Themes

Installing custom themes either you create or find online is a little more complicated, but should be painless.

First, you will need to install the Heroku Toolbet for your operating system. After you have the toolbet installed, login to Heroku.

heroku login

You will be prompted for your user name and password. Once you are logged in, clone your application to a local directory.

heroku git:clone --app YOURAPPNAME

Now you are ready to find and install custom themes. Let’s try installing the Vapor theme found here: Vapor Theme. Download the git repo as a zip by clicking the Download ZIP button on the right side of the page. Once downloaded, extract the zip file into [cloned heroku app path]/content/themes.

Navigate into the root directory of your cloned ghost blog, and add the new theme (already extracted to content/themes) to git with the following command:

git add .
git commit -m "Adding Vapor theme"
git push heroku master

Your blog should re-deploy to Heroku. Once the process is complete, navigate back to https://[HEROKU-APP-NAME].herokupp.com/ghost and login. Under Settings, click on General. Scroll down a bit to see a drop down menu title Theme. You should now be able to select the Vapor theme:

ghost_theme

Select the theme, and hit Save. Navigate back to the homepage of your blog, and you should see your updated theme! Note - if the stying looks messed up, refresh the page and clear your cache if need be.

Here are a couple sites where you can find more Ghost Themes:

If you have any questions or comments, feel free to leave them below!