Export Sage (v9+) theme as non-composer/node dependent "normal theme"

sage9

#1

Hi there,

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 :slight_smile:


Sage 9 - Production - Files to upload
#2

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.


#3

Thanks Cyberbully,

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:

app/
dist/
resources/
vendor/
LICENSE.md
phpcs.xml
README.md

Or can some of those be excluded?


#4

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?


#5

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).


#6

I’m not really following.


#7

Hi adrianvalenz,

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.


#8

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.


#9

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.


#10

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.


#11

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.


#12

Hi! @elliebartling , did you manage to make it work? I’m facing the same problem.


#13

I just managed it. We can’t use the regular upload from wordpress. We have to place the theme by FTP/Cpanel. :slight_smile:


#14

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.

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!

– Ben


#15

this is not true any more as
Capture
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