How to manage an extending theme among multiple instances

I extended the base theme with some templates. The extended theme should be used by multiple sites. I wonder, which would be the recommended way to achieve the sharing.

Let me elaborate a little on this. I started the theme extension on site A. After a while I started using the templates on site B as well. I made more changes to the extension on site B.

I want to avoid to copy the extension files from site to site.

As far as I understood theme management, there are a few options like setting up Git and refreshing the files, publishing the theme (although it is just an extension?).

The most desirable result would be a “self-hosted” or “non-public” theme, which all sites using the extension could just update like theme updates are usually handled.

Thank you very much in advance for any hint pointing me into the right direction!

@Vince42, Never looked into this scenario, but the first thing that comes to mind is Composer.

Thank you for the fast reply!
This solution would require command line access again, right?

@Vince42, Yes, but that could be triggered using a Github webhook that calls a PHP script on the server when a new version of the theme gets pushed to Github.

Having said that, instead of Composer, you could off course also trigger a PHP script that executes a git command to clone the repo containing the theme.

This is outlined in an old blog about updating a remote Grav installation (or just a theme) when pushing a new version to Github.

Alternatively you might want to take a look at the Git Sync plugin. Never used it though, so I’m not sure if it fits your needs.

It depends a bit on what type of server access you have, and what prerequisites you are working with:

  • Do you want or need the theme to version-controlled, so that different sites can use different versions of it?
    • This would be apt if the different sites update asynchronously, and you don’t want an error in one to carry over to many
    • If, on the other hand, it’s always the same for every site, there’s simpler solutions
  • Is your data, ie. the content of the sites, permanently stored only on your server?
    • This is often the case with client-sites, regardless of backups. A pure Git-setup is often the likely culprit when this data goes wrong, because every site you add increases the complexity of the overall setup
    • Restoring is easy, but cumbersome because of the same issue
  • Is there anything specifically private or sensitive about the theme, that would prevent you from pushing it to some public or private VCS-repository?
    • If not, it solves a lot of hassles, because you can rely on existing workflows such as pamtbaau mentions
  • Is file-size and duplication an issue?
    • On most hosts it wouldn’t be, but deduplication is often warranted when space is precious or many files would halter other workflows such as backups

In my opinion, the best solution is a public repository for the extension and using some package-manager to deliver the correct version to the correct site. That allows you to:

  1. Standardize the extension, its dependencies and contents - specifically avoid shipping large, uncompiled sets of dependencies or vendor-libraries
  2. Install the version you want using Grav’s Package Manager, Composer, Node’s Package Manager, or pretty much anything that can push code
  3. Test out beta-versions on beta-sites without breaking anything

You can also avoid the painful process of running Grav as a multisite or with elaborate streams, because this setup doesn’t prevent you from copying sites or symlinking extensions.

1 Like

@pamtbaau Thank you for your input! I will have a look at the mentioned solutions and plugins!

@OleVik After reading your valuable input I will also consider making the theme publicly available, as there are no secrets in it. :wink: