我如何将jekyll _site目录推送到gh-pages分支,并将源代码保留在master? [英] How do I push jekyll _site directory to gh-pages branch, and leave the source in master?
问题描述
我有一个由页面组成的基本jekyll站点(不是帖子),但是因为我想在列出页面时对页面进行排序,所以我不得不使用 Jekyll-Sort 插件(有点怪异的排序页面并没有内置到jekyll中)。
因为我使用的是插件,无法利用GitHub的自动jekylling。因此,我想将项目的源代码推送到 master
分支,然后将 _site
目录推送到 gh-pages
分支。
我无法弄清楚如何做到这一点 - 我尝试添加一个git repo在 _site
目录中将其推送到 gh-pages
,但每次运行 jekyll
它会擦除整个目录,并且会丢失 .git
文件夹。
有什么建议吗?或者一种本地排序方式?
一个不那么痛苦的解决方案:
- 检查您的分支,您的分支源代码位于何处(可能
src
或master $ c $ (可选:将
_site
添加到.gitconfig $ c $> c>,所以它被忽略,如果还没有完成的话)
删除 -
将您的repo的
gh-pages
分支克隆到_site
目录中:
$ git clone -b gh-pages`git config remote.origin.url` _site
_site
目录: $ rm -r _site / *
最后步骤:让jekyll build,commit&推::
$ jekyll build
,
cd 转换为 _site
:
$ cd _site
将所有文件作为提交目标:
$ git add
git提交-am'是的。从子目录'
构建并将您的网站推送到GitHub-Pages:
git push
。
I have a basic jekyll site consisting of pages (not posts) but, because I wanted to sort the pages when I listed them, I had to use the Jekyll-Sort plugin (kinda weird sorting pages is not built in to jekyll).
Because I'm using a plugin, I can't leverage GitHub's auto jekylling. So I'd like to push the source code of the project to the master
branch and just the _site
directory to the gh-pages
branch.
I can't figure out how to do this - I tried adding a git repo inside the _site
directory to push that to gh-pages
but every time I run jekyll
it erases that entire directory and I lose the .git
folder.
Any suggestions? Or a way to natively sort?
A less painful solution:
- Checkout your branch, where your build-source is located (maybe
src
, ormaster
) - (Optional: Add
_site
to your.gitconfig
, so it get's ignored, if not already done) Remove all content of the
_site
directory:$ rm -r _site/*
Clone your repo's
gh-pages
branch into the_site
directory:$ git clone -b gh-pages `git config remote.origin.url` _site
Final steps: Just let jekyll build, do commit & push:
$ jekyll build
,
cd into _site
:
$ cd _site
,
target all files for commit:
$ git add -A
,
commit them:
git commit -am 'Yeah. Built from subdir'
and push your site to GitHub-Pages:
git push
.
这篇关于我如何将jekyll _site目录推送到gh-pages分支,并将源代码保留在master?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!