I was wondering if anyone had any experience using their own custom theme on multiple sites and what approach you took. For example, sites with similar snippets/templates + functionality but different content, images, and branding. Something similar to how you can import components in a JS front-end framework. If possible, I would like to update the snippet/template/functionality in one place and have it update across all sites.
Ideally, I would like to avoid having to manually transfer code + files from one project to the next. I was looking at using Git submodules to do this, but the hosting server I am with (Cloudways) does not support submodules when deploying from Github.
If anyone has implemented any type of system like this, I would love to hear about it. Any and all feedback is very much appreciated. Thanks
Depending on what’s included in your ‘component’, you could set it up as a Kirby Plugin. Your Kirby plugins can include frontend code - templates, snippets, assets, etc. - as well as backend code - controllers, models, etc. They can even include other plugins.
You can build your plugin to be installable via composer, and then list it in Packagist - it’s free. This is by far the easiest way to include your plugin in your Kirby projects and keep it up-to-date, as you update your code, across all your sites.
In Cloudways, in order to autodeploy your site when you commit your changes to your git repository, you have to manually setup a script that responds to webhook calls from your git provider - as described here. In that script, after you’ve pulled your git changes, you’d need to call composer init to make composer ‘load’ your plugin fresh from Packagist with every deployment.
Sorry, I should’ve expanded. I meant the same templates, snippets, and such being used across multiple sites, but each site would have different styles, images, and such.