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?
Thanks in advance, I look forward to your replies
Just compile the assets first and you don’t have to distribute it with the node dependencies.
The composer stuff will always be required. So you’ll have to include the vendor folder.
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:
Or can some of those be excluded?
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?
You can do the build from assets on your workstation/deploying machine, too, see
You would have to adjust the upload method (e.g. ftp command instead rsync).
I’m not really following.
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.
composer install will add all the necessary php code for a Roots theme to your project.
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.
What if I want to sell WordPress themes but create them with Sage 9? Preparing what I created into a theme people can download and install.
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.
Hi! @elliebartling , did you manage to make it work? I’m facing the same problem.
I just managed it. We can’t use the regular upload from wordpress. We have to place the theme by FTP/Cpanel.
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
index.php files within the main theme directory.
See this other topic for more background story on the issue: https://github.com/roots/sage/issues/1938
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