First off, I really like what Sage brings to WordPress theme development.
My only concern is that most of the sites I build are deployed on (or rather, uploaded to) shared hosting. Unfortunately, nearly all shared hosting services do not allow packages to be installed on the server via composer/npm.
Is there any way of “exporting” or “packaging” a completed Sage theme into a conventional WordPress theme?
If not, would something like this be possible? And also, anyone keen on exploring the possibilities with me?
Perhaps this can help some other newbies as well. So after running yarn run build:production, the only files and folders required for the theme to work are:
Ok so you just create a .zip file with those folders and files and anyone can just upload and activate the theme to their WordPress site? You don’t need to run composer install in the theme’s directory?
Yes, you are right. But this will only work if all your dependencies (composer stuff) and compilations (node/yarn) have been successfully loaded and compiled on your system.
Running composer install will add all the necessary php code for a Roots theme to your project.
You also have to compile your javascript assets with node/yarn before adding your theme to your WordPress installation.
On shared hosting environments the ability to run composer/node is typically not available, so you have to do composer install and yarn run build:production on your computer before you can upload it to your site (whether you choose to upload it through FTP or as a ZIP file is a personal preference).
If your WordPress installation is on a Digital Ocean droplet (or any other setup where you are the sysadmin), you can ssh into the server and install all your composer dependencies and compile your assets using the above commands. This will only be necessary if you did not/cannot run these commands on your local machine - for instance when you are developing on the live server.
I hope this helps a little, let me know if there’s anything else I can help with.
I mean that you can do all the preparation on your workstation and then upload the resulting files using FTP - which is usually the available transport in shared hosting.
As with the solutions above, you can run composer install and yarn run build:production, zip up everything in your theme directory, and distribute it however you like. It can’t be said enough that Sage does not rely on any special functionality or moving parts once it has been built for production.
Did this end up working for you guys? I tried this with Sage 9, but when I install the theme via .zip or ftp, Wordpress can’t find index.php, style.css, or functions.php and treats it as a broken theme.
For anyone that is having trouble installing Sage themes using the “normal” WordPress installation process (ie by uploading them from within the WP Admin) – this is because Sage themes don’t have the style.css, functions.php and index.php files within the main theme directory.
As well as this theme for some guidance on how you can update the codebase to allow it to be uploaded and activated through the WordPress admin: https://github.com/roots/sage-installer/issues/3
Hope that helps make your themes more portable to other environments!
this is not true any more as
i dont know weather it worked earlier but zipping up the files and uploading it results in missing resources as wordpress wants them in the root folder and not sub-folders