Best practices for how to update slightly customized theme most efficiently?

Hello! Relatively new to the platform and recently came to understand from staff and the forum (thank you!) that I may sometimes need to update my theme (Headline) manually when Ghost adds new features because I added some theme customizations.

I wanted to make sure I’m doing this right because I feel like I’ve possibly overcomplicated it… I have some custom coding related to comments (Cove) and displays related to reading time, timestamp, URL, etc. It’s 5-6 basic cosmetic things. But they go into different files and I don’t have a great roadmap for what all of them are now that I’ve already done the work.

Recently I wanted to use the version of Headline WITH search because for some reason mine did not have that. So I downloaded the theme again and then went through all 5-6 customizations I had just done — just so I could use native search. I think maybe I just could have added some kind of search / handlebars into my already custom version? - but I wasn’t sure and didn’t want to miss any other code changes in the update.

Now - Ghost has added comments. I’m on Ghost (Pro) – so I think I can just turn on comments from the settings menu and go from there…

But I guess I just wonder what I do next time there’s some improvement related to the Headline theme: (A) how do I learn about it? and (B) what would I do to take advantage of that AND keep my customizations, e.g. create some kind of very clear memo to myself about exactly where all the custom code goes so it’s easy to drop it in in the right places? Or would there usually be some kind of new Handlebars helper that I would just put in the right place?

Or is it only Ghost but not Headline that would be updated?

Not sure how best to approach this. Thanks for any input!

There are a lot of different approaches to this issue, and you’ll need to find the method that works best for you (I list 3 below). That being said, offloading changes to Code Injection or just keeping things in separate files when possible will always make your life easier.

For keeping up with changes, all Ghost official themes are open source, so you can see the changes on their GitHub pages. For Headline, you can see that the Readme file was the most recent update. Clicking on the ## commits will show the history of theme changes.

Methods for keeping up to date

  1. Manual
    Watch GitHub to see the changes and then manually copy those changes into your own theme. This is the most straightforward and often the simplest way of going about things. Themes usually change incrementally, so this method isn’t as tedious as one might expect.

  2. Use software to detect changes between your theme and the official one
    @mjw mentions using an app called Meld for this. More details here: Make changes to a theme to upgrade easier? - #2 by mjw

  3. Fork the official theme in GitHub
    This is the most advanced technique and requires some fluency with GitHub. This site goes over the basic process: How to build on top of the Casper theme in Ghost

If anyone has any other ideas, please shout :speech_balloon:

2 Likes

just wanted to chime in on @RyanF awesome answer. I stumbled upon this a while back:

Very helpful to automate theme customizations, big or small.

To ans your questions:

I too often go to the theme’s Github page to check for new releases versions/changes.

I add a readme file to remind myself which files have been changed, and a comment (e.g. #cust) at the beginning of the custom code so i can Ctrl + F which places have been modified.

you might find it useful

1 Like

Hey @RyanF, a quasi-related question if you don’t mind.

I see that in the comment below yours that Ghost’s GitHub Theme Deploy integration is mentioned, something that I should finally get off my butt and actually set up (now that I’m developing locally while using VS Code and GitHub Desktop in place of developing online while using… Brackets :roll_eyes:). I also see that there’s two links mentioned in the linked-to-post:

Are those two essentially the same things, or two different things doing a similar action?

Otherwise, if they are essentially the same thing I see they’re suggesting to insert somewhat different code into files with different names. The former says the following code should be inserted into a new file called .github/workflows/main.yml:

name: Deploy Theme
on:
  push:
    branches:
      - master
      - main
jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@master
      - uses: TryGhost/action-deploy-theme@v1.4.1
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}

The latter says the following code should be inserted into a new file called .github/workflows/deploy-theme.yml:

name: Deploy Theme
on:
  push:
    branches:
      - master
      - main
jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: Deploy Ghost Theme
        uses: TryGhost/action-deploy-theme@v1.6.0
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}

You can see that in comparing the two, and in particular the first three lines (in the latter) under steps, two lines have been adjusted and one of them is new. Shall I take it that I should disregard the file name and code in the former and instead utilise the file name and code in the latter?

I think we just need to update the docs on the first page, but both should work just fine. This is a process that takes a little bit of work to set up, but it’s just pure magic after that :magic_wand:

The name of the file isn’t important, you can call it whatever you want. Just copy in the yaml code from the second example. Create an integration in Ghost admin and then copy those secrets into your GitHub repo. (These steps are spelled out in more detail in the link: Deploy Ghost Theme · Actions · GitHub Marketplace · GitHub)

After that, anytime you push to your Ghost repo, your theme will be updated automatically! One thing I just started doing is running npm version patch before pushing to GitHub. This will update the patch version of your theme from 1.0.0 to 1.0.1, e.g. It makes it easier to see in Ghost Admin that your theme was indeed updated.

Anyway, if you have trouble or questions, lmk.

1 Like

I got it working, thanks!

One suggestion though. Seeing how those docs need updating, perhaps you might want to make it clear that the GHOST_ADMIN_API_URL and GHOST_ADMIN_API_KEY portions in the yaml file shouldn’t be replaced with the actual API_URL and API_KEY from the Ghost Integration page, seeing how that’ll apparently, uh, screw things up. :roll_eyes:

1 Like

I recently set up GitHub Theme Deploy on another theme and instance, but couldn’t see the changes active on the site. I thought things weren’t set up properly but then noticed that the theme had in fact uploaded from GitHub but didn’t get activated. Am I correct in surmising that when changing the version number the newly updated theme must be manually activated from within the admin?

As long as the theme is the same and already active, then you shouldn’t have to manually activate it.

Is the theme being added as a new theme or as an update to the existing one?