Setting different asset paths in config for different environments


I have Kirby set up using the suggested Multi-environment configs from the docs.

Development environment config:

Production environment config:

I’m looking to have different asset path for each environment.

Development environment asset path:

Production environment asset path:

What’s the best way to set the different asset paths inside each config?


I think the easiest way to do that, is via a config setting:

E.g. in /site/config/

c::set('assets.path', 'dev');

In your header

<?= css('assets/' . c::get('assets.path', 'prod') . '/app.min.css') ?>

Note that I’ve used prod as a fallback value here, in case the assets path is not set. Instead of only setting the subfolder, you can of course set the path to assets/dev' etc. instead and modify thecss()`helper accordingly.


This is great! Thank you! I didn’t think it would be as easy as that.

Are there any downsides to using this technique as you start to use it for more and more assets? - say I’m using this for 50 assets on a page?


I don’t see any downsides; the only downside is loading 50 assets per page.


My hint:
Use less or sass to avoid so many css-files! Google is your friend for details…

May be you want to use different snippet files header.php, one for each environment.


Yes, 50 assets would be a bit extreme :smile: I was more concerned if there were any speed issues on Kirby’s side as this method isn’t “the norm” I guess.

FYI, I’m using Gulp to compile assets for both environments. When I compile for production these assets are minified and uglified before deployed.

Anyway, thank you for all your help :slight_smile:


No, speed-wise, I think the call to the config setting is the last thing you need to be concerned about. If you use it multiple times in a template, I’d store the value in a variable, anyway.