How to manage common CSS across multiple sites?

Tagged: ,

Author Posts

Norm6257

I’m looking for suggestions on how I can manage common CSS across multiple sites. Right now my process is to create the desired CSS on one site, and then I have to go to every other site and create a new folder, create new selectors, and paste in the CSS. And then if I sometime update the CSS I have to go to every site and do the same.

I’m looking for suggestions for a better process.

I can’t just export the MT file because there is site-specific code… I need to have common CSS that gets updated on every site but still allows site specific CSS (that could override the common CSS based on load order.)

Also, is there a way to copy a MT folder from one site to another?


Sebastian

Hey Norm,

You can export specific folders via Settings > Import/Export > Export.

Download the export as a zip file, then install it on the other site and import it into the UI with the merge option selected. Settings > Import/Export > Install & manage.

For common CSS that is the same on all sites, I recommend creating a dedicated WordPress install for that. Create your common CSS in Microthemer, and then on the other sites you can enqueue the common stylesheet by adding some code to your child theme’s functions.php file

https://developer.wordpress.org/reference/functions/wp_enqueue_style/

function my_common_css() {
        wp_enqueue_style( 'style-name', 'https://url-for-common.css' );
}
add_action( 'wp_enqueue_scripts', 'my_common_css', 5 );

By setting the add_action priority to something low like “5” you ensure the common CSS loads before the site specific CSS. MT uses a priority of something like 99999 by default, and this can be customised via the preferences.

I hope that helps. Please let me know if you have any more questions.

Thanks,
Sebastian

You must login or register to reply to this topic.