I am using the gem "jekyll-assets" on my site and it fails when pushing to github pages. I have read that a way around this is to build the site locally, which builds just fine, and then push it to github pages. The examples of people doing this, however, are using a project repository and they are pushing the site to a "gh-pages" branch. I am doing this site for myself and the setup for this suggests using the master branch under the repo .github.io. How do I push a local jekyl build to a site with this setup?
3 Answers
You need to push only the content of the _site
folder. Nothing else, nor the folder itself.
If you are setting up a project site, push the content to the gh-pages
branch. If it's your user website, the repo must be named username.github.io
and your site root needs to be the master
branch.
Let me know how it goes! :)
Hope to have helped!

- 2,025
- 1
- 13
- 18
-
Worked perfectly! The key was copying the contents of the '_site' folder and not the folder itself. I have ended up putting the original repo in an other branch, build it, and then switch branches and push only site contents to the master branch. For others, here is another [guide](http://www.sitepoint.com/jekyll-plugins-github/) I found after this answer. – npresco Apr 04 '16 at 13:38
-
After two years, hasn't been added yet an option to handle this using only the master branch? – rraallvv Aug 08 '18 at 16:03
-
@rraallvv not sure, I use only GitLab Pages now, better check the GH Pages docs again – Virtua Creative Aug 08 '18 at 16:09
Here a windows batch file that pushes generated files back to github. Name it site_publish.bat and put it into the root of your project.
@echo off
cd /d "%~dp0"
rmdir _site /s /q
call jekyll build
git --git-dir=.git --work-tree=_site add --all
git --git-dir=.git --work-tree=_site commit -m "autogen: update site"
git --git-dir=.git --work-tree=_site push

- 1,379
- 15
- 16
-
didn't know about `--work-tree` flag, cool; why are you using `--git-dir` flag, when it works without it? – Rami Chasygov Apr 15 '18 at 20:03
-
@RamzanChasygov honestly, I don't remember. Maybe you're right. I've not tested code fully. – yuliskov Apr 27 '18 at 20:23
You may want to try jgd
command line, which automates all the steps suggested by other answers, in one simple call:
$ jgd
The site will be packaged and then deployed to the gh-pages
branch of your repo, provided you have all permissions configured. More about it in this blog post of mine: Deploy Jekyll to GitHub Pages

- 102,010
- 123
- 446
- 597