Local development of custom theme setup

I’m wondering how best to set up a local development environment to work on customizing a theme. I’ve read numerous posts on here, and followed not the author of this posts suggestion, but the followup comment suggestions: Developing Themes Across Machines w/ Git

That is:

  • I already have my custom theme in a git repo
  • Installed ghost locally:

ghost install local
cd content/themes
git clone https://github.com/mycustomtheme/

If this worked, I’d be able to make changes in the content/themes/mycustomtheme/ folder, see those changes locally, and commit them to my repo.

This does not work though, the theme does not show up in the admin panel Design -> Installed Themes section, I assume because there are some ghost database items that get set when you upload a theme via the admin console?

So, is the best practice for developing custom themes the following? If we clarify here maybe this will help others in the future:

  • Install ghost locally. You only need to do this one time:

ghost install local

  • Once you have the beginnings of a theme, .zip it up, as described in the Ghost docs for creating custom themes. Upload this .zip in the admin console. This will generate a new folder in /content/themes/ Lets say we’ve named our theme “awesometheme”. This will generate a folder /content/themes/awesometheme/
  • Make the entire /awesometheme folder a git repository
  • Now you can make changes to your theme in /content/themes/awesometheme/ and see the changes locally.

Following up with that, if you now want to work on your awesometheme theme on a different computer:

  • Install ghost locally. You only need to do this one time:
    ghost install local

  • Clone your theme repository into any random location on your computer

  • .zip up the theme

  • Start ghost, and in the admin console upload your theme .zip

  • Stop ghost

  • Go to /content/themes and delete the /awesometheme folder that was created by ghost

  • In /content/themes, clone your awesometheme repo

Now you’ve got your theme’s git repository in /content/themes, and can work on it locally, commit changes to the git repo, etc. Seems convoluted, I’d love to hear if anyone has a better system.

There is not. The only thing that changes is what theme directory is active. Make sure you restart ghost after cloning the theme :slight_smile:

1 Like