/ OpenShift

Managing Ghost Themes with Git

Due to using OpenShift to host my Ghost setup I can't just stick a theme folder in Ghost's content directory and switch to it. Instead, what I do is manage the themes using git, a free open-source version control system.

If you followed my first post on setting up Ghost on OpenShift this should work as written. If you've got things set up another way you might need to mess with the details (especially your repository address) to get it working.

Installing ghost themes Using git

First things first, you need to make a copy of your Ghost installation's repository. To do this you need the address of your sorce code. To find this in OpenShift, log in and click the gear icon to the right of your application.

OpenShift Applications Screen

The ssh address for your repository is then shown on the right (the red bit):

OpenShift Source Code Link

Now you have this, you can create your clone. I use OS X, but these instructions can be easily adjusted to any environment.

Start a new terminal session (or cmd window, BASH shell, whatever) and navigate to a suitable location to keep your repository, then run the following. The repository address is the one you got from OpenShift earlier:

git clone [repository address]

This creates a new subfolder from your current directory with the name of your application. Change your working directory to this newly created one. My app was inventively called nodejs, so I ran cd nodejs.

Next up is adding your theme's files to your local repository. Copy your theme's files to ghost/content/themes then run the following from the top level (in my example the 'nodejs' folder) of your repository:

git add .
git commit -m 'Adding new theme'
git push

This will take a little while as it will commit the changes you made and restart your application. Once it's done (should be a minute or so) you can reconnect to Ghost in your browse, go to settings and your theme should be in the dropdown box.

Removing a Ghost Theme

If you followed the steps above, this is pretty easy. just go to your themes directory, delete the theme folder you don't want and form your repository's root folder run the following:

git add .
git commit -m 'Adding new theme'
git push

This will restart your openShift app and the theme will be gone. Bear in mind that removing the theme you're currently running will cause all sorts of problems for Ghost and you may not be able to get to your settings to change to another theme. Make sure to change to your new theme before deleting an old one if possible. If you've jusmped the gun and deleted your current theme, just re-add it to your repository (as above), push the change, change your theme then remove it again.