Sage 9 parent/child theme

I’m pretty new to Sage and it’s been awhile since I’ve done any WP development, so please bear with me. Does anyone have a resource for best setting up Sage so that I can easily keep my project up-to-date with Sage 9’s development? It seems like configuring Sage as a parent/child would suit my needs, but I’m not sure.

Here’s what I’m thinking:

  1. Configure Trellis as usual
  2. Set up Bedrock as usual
  3. Clone (or fork?) Sage into project as parent theme
  4. Clone (or fork?) Sage into project as child theme
  5. Maintain and update Trellis/Bedrock/Sage via Git (or Composer?)

In this setup, would I be using Git submodules? Would composer update be better for keeping Sage in sync with master?

Any advice or feedback welcome.

Sage isn’t set up to be a parent/child theme, it’s a starter theme you build from. I do agree that with Sage 9 especially being in active development, you will want to keep it updated. I would suggest adding the Sage repo as another git repo on your project, and then you can cherry pick commits from it. Something like this: https://gist.github.com/kalenjohnson/9ed257d8afb81e571a4b

Going off memory, something like this:

git add sage git@github.com:roots/sage.git
git fetch sage
git cherry-pick -Xsubtree=site/web/app/themes/sage 517be2a88318de51f51397066575ab07fae825a1 --strategy=recursive

Obviously you replace the sage name with your theme name, and you also update the commit checksum with the commit you want to add.

Then continue cherry picking commits in order from when you cloned to the latest commit until you’re up to date. And you can generally skip the merge commits as those are blank commits.

6 Likes

That’s really helpful. I’ll try to integrate that workflow and see how it goes. Thanks!

This step is performed by git add sage git@github.com:roots/sage.git? Or do I have to add another remote to my project’s repository?

Sorry but I’m interested in it and I would like to understand this thing a little bit better, thank you.

You’re correct, that’s the remote you would add if you want to pull commits from the Sage repo.

1 Like

How did it go? I would like to keep the sage repo + create a repo for my theme too.

Is this still best practice for using sage and keeping it updated?

Best practice is to use Sage as intended (as a starter theme) and not worry about keeping it updated