Trellis production deployed successfully - Can't find Sage theme

Pretty excited to have made it this far but I’m missing something. I can’t get the Sage theme to show up on my production server on Digital Ocean. I’ve been following these instructions - https://github.com/roots/roots-example-project.com

  • I have successfully setup up a local site dev with vagrant up. After some ssh frustrations everything seems to be in order.
  • I have successfully provisioned server: ansible-playbook -i hosts/<environment> server.yml
  • I have successfully deployed my site: ./deploy.sh <environment> <site name>

On the local dev Sage theme loads by default and no other themes are listed in the wordpress/appearances/themes tab in backend. On the DO site all the regular themes show in the backend and no Sage. I feel like I’m close. What am I missing?

This I definitely did for bedrock:

WP_DEFAULT_THEME.

In site/config/application.php add define('WP_DEFAULT_THEME', 'sage');

Thanks guys - I know it’s gonna be awesome when I get all together.

The repo cloned during deploy is assumed to include your theme.

  • If the repo you’ve specified does not include the theme, that could be the problem. Add the theme to the repo and deploy again.
  • If the repo does include the theme, you might ensure that you have the latest Trellis to avoid the problem fixed by roots/trellis#299.

If the problem persists, let us know and we can troubleshoot further.

Thanks, I believe I have the latest Trellis. I used git clone git@github.com:roots/trellis.git this morning.

In group_vars/production I had:

repo: git@github.com:roots/bedrock.git

Should it work if I use this as the repo instead?

repo: git@github.com:roots/roots-example-project.com.git

Do I need my own bedrock repo for it to work? I’m really just trying to get the ball rolling on this workflow to decide it if it is worth moving forward with, or over my head. Trying to keep it as simple as possible so I can get the hang of it.

The roots/bedrock repo doesn’t include the theme, so when the deploy cloned roots/bedrock, the theme never made it on your server. You can use roots/roots-example-project.com to test that sage can appear on the server. In this case, you’d also need to uncomment subtree: site, as it is in the example project.

You can use the roots/roots-example-project.com repo to test and demonstrate to yourself that the deploy works, the theme appears, etc. Of course, once you’re ready to make your customizations to your theme, bedrock, etc., that’s when you’ll want your own repo/fork, so that when you deploy that repo, it deploys your custom work.

For your repo structure, you could combine sage, bedrock, and trellis into a single repo like the example project demonstrates or at least combine sage and bedrock into one WP project repo for your site.

2 Likes

Thanks @fullyint! Uncommenting the subtree: site line fixed it. I appreciate the help. Excited to be moving forward with these great tools.

2 Likes

Hello,
I’ve searched a lot and it seems like this thread is the closest to addressing what my issue is. I am following the example as far as I can tell. Specifically, Sage isn’t showing up as a theme on my remote server but everything else seemed to deploy successfully.

I tried to follow the advice given in the answer from @fullyint but there isn’t anything I can change or advice I can follow that seems to want to provide for the theme to show up on my remote server.

Currently, my repo is getting a compressed version of the theme in the site/web/apps/theme folder and my server site/web/apps/theme folder is empty. Is the theme not decompressing correctly? Is it even supposed to get compressed when it gets uploaded to the repository?

Any help is appreciated and if there is anything I can provide that I’m not, please let me know. I’m so close…

@worldwidejamie If you haven’t tried it already, you could try setting your repo and repo_subtree_path variables to the exact values in the example project, then deploy. If you then find the sage theme in site/web/app/themes on the remote, as expected, you’ll know that the problem probably is with your custom repo.

I’m not sure I understand. If you mean you are committing a zipped version of your theme and pushing that to your repo, I am not aware of anyone doing that and I expect it probably would cause a problem. If testing the example project repo worked, I’d recommend using that repo as a guide for how your repo should be structured, whether files should be compressed, etc.

In case you are intentionally zipping/compressing theme files in attempt to reduce the size of the large node_modules directory before committing, search around Roots Discourse for threads explaining how you would probably only ever commit asset dir files (not node_modules nor dist) and use the build-before.yml deploy hook to build theme assets and sync them to your remote server at time of deploy.

Hello,
Thank you for responding.
I did your suggestions and the results were slightly different but maybe I should back up to simplify the issue a little bit and this might actually change my question even if I’m still eventually trying to get an answer to the original question.

I have not actively compressed anything in any commits to my repo. I’ve merely done whats suggested by the trellis documents. However, when I go into my apps folder in site, this is the name of the only file on my repository:
‘sage → 8d7bcee4c461 [8d7bcee4c461]’

On my remote server, the same location held nothing. When I attempted to switch the source repo to the example I did get some population but it was minimal:
a ‘dist’ file was uploaded with ‘fonts’, ‘scripts’, and ‘styles’, and an assets.json file was uploaded.

I’m thinking I should probably start over with my repo. I’m not in too deep and it’s not going to be a detriment to my project. I can’t figure out why there seems to be an error or why the file is compressing… if it is at all. Maybe there is just an error.

All said, thank you for your help. If any of this gives an indication of anything specific I might be missing and you or anyone else can help, great. If not, also great, but I’m going redo my repo with a fresh version of sage and server provisioning files. I’ll update with anything I find out.

As always, everyone’s time is appreciated.

I have the same issue trying to deploy to staged. When I look in my repo everything is there until I get to my theme folder which is a greyed out looking folder that I can’t open. When I go to the theme folder in my site there is just an empty folder with my theme name.

I’ve now updated build_before.yml, uncommenting the lines to replace ‘sage’ with my theme name. After running this I get the dist folder in my theme directory but none of the other theme files like base.php, single.php etc.

I think that while I’ve been committing changes to git, changes to my theme have not been included. When I run git status it always says:

modified: site/web/app/themes/atss (modified content, untracked content)

However if I do:

git add site/web/app/themes/atss
git commit -m "Updated theme"
git push -u origin master

and then when I run git status again it still says:

modified: site/web/app/themes/atss (modified content, untracked content)

Where am I going wrong? I’m sure it’s something simple but for the life of me I can’t work it out. I’m sure you can tell I only have a tentative understanding of git. I really want to get to grips with all of this but it feels a steep learning curve.

This forum has been really helpful so thanks to all those who contribute so much.

This is because the theme folder still has its own .git directory in it, so Git is treating the theme directory as a submodule. You need to delete the .git directory from your theme folder and then git add the theme folder to your project repo, then git commit and git push

Ok, I’ve tried to follow your instructions but the theme’s still not in the project repo. I’m clearly doing something wrong.

First I deleted the .git directory from the theme folder.

Then:

EFW:atss bizz$ cd /Users/bizz/Sites/atssstar.com 
EFW:atssstar.com bizz$ git add /Users/bizz/Sites/atssltd.com/site/web/app/themes/atss 
EFW:atssstar.com bizz$ git commit -m "Adding theme"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
	modified:   .DS_Store
	modified:   site/web/app/themes/.DS_Store

no changes added to commit
EFW:atssstar.com bizz$ git push
Everything up-to-date
Everything up-to-date

I hope it’s obvious to you where I’m going wrong as I really can’t work it out. Thanks for your help.

What @MWDelaney says is correct. I thought I had updated with my findings but I didn’t… The solution for me was to rebuild my theme from git. So for example when I originally cloned everything into the fresh new project folders, at some point
rm -rf /.git
didn’t work to remove the .git file in my sage theme folder and it got left behind without me realizing it. I tried to do the above and just remove the .git files from my theme folder but that wasn’t enough. The process didn’t work until I tore the project down and rebuilt it again.

That said, I’m sure that was a drastic move but I one I was comfortable making because I hadn’t customized anything yet.

After I reinstalled Trellis, Bedrock, and Sage and making sure my .git ducks were in a row, I haven’t really had any problems.

Thanks @worldwidejamie and @MWDelaney. The thought of rebuilding is quite scary but I’ll give it a go.

I honestly don’t know if you have to rebuild.
I only did it because I had the luxury of not having had customized anything and wasn’t familiar enough with git to get done what I needed very quickly or efficiently.

That said, it certainly didn’t hurt having the opportunity to go through and practice setting up an installation again.

Good Luck though! If you find a way to do it without needing to rebuild, I would certainly be interested in hearing it.

@worldwidejamie I had a bit more of a search around and found this: http://stackoverflow.com/questions/19584255/what-does-a-grey-icon-in-remote-github-mean

I think I must have run git init from my theme folder at some point and managed to create a submodule (whatever that is). Anyway, I’ve got round this by:

  • removing the .git folder from both my theme folder and my project folder
  • renaming the git repo I was using (rather than deleting so I had a backup if necessary)
  • creating a new git repo with the same name as my original repo
  • reinitialising git in my project folder
  • adding all my files to the new git repo

I’ve just checked and the new repo contains the theme folder.

Deploying to staging now … and it’s worked! I can’t believe it. I could cry.

Thanks for your reply earlier, it made me investigate further. I think I was panicking too much to think it through properly at the time. Hooray!

1 Like

I’d like to add one more question/comment to this discussion, since the advice here seems to conflict with what I’ve read on in other threads. The solution here is to make sure you have one big repo for trellis and bootstrap and sage, but I thought the best practice was to keep each in its own repo using submodules?

At this stage I have a deployment from a repo with trellis and bedrock in it, and my sage theme as a submodule, but installing the submodule on the staging server is going to require setting up git config and the right SSH keys so I can access the repo from the remote server. This doesn’t seem right. Can someone explain the best practice here?