Closed ortonomy closed 6 years ago
Unfortunately, no. Github picks and approves certain plugins. They have not added Jekyll-Pug.
😢
You could probably still get a usable setup with some scripting magic.
You would create a second repository. When you're ready to deploy, it would initialize git in your Jekyll build folder and then add your second repository as a remote. Finally, it would push changes to your second repository.
A little hacky, but once you get the system set up it should be pretty smooth.
I was going to create a Jekyll Plugin that would do exactly this, but then lost motivation to do so.
@DougBeney -- thanks for this. I had come to the same conclusion, and that's what I did!
I have my site on gh-pages
branch and the actual site on master
. I have the master branch cloned and tracked inside _site
and then keep_files
for .git
folder and .gitignore
in _config.yml
.
Putting details here for anyone else who wants to do the same.
Very cool! Thanks for sharing.
@ortonomy could you please share a more in depth view on how to do this? 🙏
I got the same setup as you described above, but here's what I don't understand:
gh-pages
branch, _site
folder which is tracking master
branch.@lucasnantonio -- sure.
It's important to note that the same git repo is tracked twice, but on different branches, and nested in different folders.
git clone [your repository]
gh_pages
branch, or create it.bundle exec jekyll build
cd [repo]/_site
git clone [your repository] ./
master
branch._site
folder. That means the only folder you should have left is _site
inside [repo]/_site/
(brain melt!)[repo]/_site/_site
to [repo]/_site/
[repo]/_site/_site
(it's not longer needed).[repo]/_site/
This is the basis of having your site on master
and gh-pages
as the source branch
However, you need to make sure that the .git/
repo files and .gitignore
files are not removed every time you run bundle exec jekyll build
, so you need to edit your config.yml
file and add these lines:
keep_files:
- .git
- .gitignore
Then you can run the build process any time you want, and it won't kill the repo.
Then commit master
every time you want to push a new version of the page, or commit gh-pages
branch to remotely store the source files.
My github.io
repo is here if you want to see it as an example.
Thanks for sharing! I referenced this issue in the readme file.
You can also use git worktree
: That will be one clone, multiple folders (one per branch).
Also you can use a CI to build automatically to gh-pages
branch whenever you commit to master
.
Incase this is helpful to anyone, I set up a git repo in _site/
and then added a post-commit hook to the main repository (put below script in .git/hooks/post-commit
). You will then be prompted after each commit on whether you want to add an equivalent commit to the _site
repo.
Warning: Not thoroughly tested. Review code and use at your own risk.
# Exit on error (suffix ` || :` to prevent this)
set -e
echo -n "" >&2
run_summary()
{
echo -n "$1... "
shift
# Print errors in red bold
echo -n "\033[01;31m" >&2
# Print "Success" or "Failure" in green or red bold
"$@" >/dev/null \
&& echo "\033[01;32mSuccess\033[0m" \
|| (c="$?"; echo "\033[01;31mFailure\033[0m"; exit "$c")
echo -n "\033[0m" >&2
}
echo -n "\033[01;1mDelete _site/, compile, and commit? (y/N) \033[0m"
read answer < /dev/tty
if [ "$answer" != "y" ]; then exit; fi
base=$( pwd )
message=$( git log -1 --pretty=%B )
mv _site/.git _site-git~37uh6 2>/dev/null || :
run_summary "Removing _site" rm -rf _site
mkdir -p _site
mv _site-git~37uh6 _site/.git 2>/dev/null || :
git stash --all
trap 'cd $base && git stash pop -q 2>&1 | grep -v "already exists, no checkout"' INT TERM EXIT
run_summary "Building" jekyll build
cd _site
git init >/dev/null
git add --all
run_summary "Committing" git commit -m "$message"
cd ..
# XXX: already handled by trap EXIT
# git stash pop -q >/dev/null 2>/dev/null
Is it possible to use this plugin with github pages? (user.github.io)? I used it and then uploaded to my github site, but ostensibly doesn't seem to work. Any thoughts?