
Cover image by the magnificentAndre Wallin
One of the caveats ofGitHub Pages is that it won’t automatically build your site if you’re not using the GitHub Pages Jekyll gem. On top of this, you can’t use any Jekyll plugins that aren’tsupported by GitHub Pages.
That being said, GitHub will deploycompiled code for you, either from the/docs
folder, agh-pages
branch or from themaster
branch.[ref]
The solution I’m using right now means still I’m able to run my build process locally and auto-deploy with a single command.
So for this to work, I’ve set up two branches for my site:
master
contains my Jekyll compiled_site/
folder, which GitHub will deploy each time it’s pushed..nojekyll
should be added to this branch so GitHub doesn’t attempt to compile it.
sources
contains the full repo, with the Jekyll source files.- This method could work with any static site generator.
_site/
should be added to the .gitignore on this branch, so you don’t commit the changes in there.
I’ve written a simplenpm shell script that runs withnpm deploy
, which is essentially an alias for the following string of commands:
bundle exec jekyll build &&cd _site/ &&git add . &×tamp=$(date \"+%s\") &&git commit -m \"automated deployment $timestamp\" &&git push origin master &&cd ..
Each time I want to deploy:
- The
jekyll build
command compiles and builds my static site inside the_site/
folder. - We then change directories to
_site/
, which has a .git config, set to themaster
branch of the repo. - The script then commits all changes (+ timestamp), pushes master and returns to my source folder.
That’s it! So now, once I’ve made changes to my site or content, I can still have my site built and deployed with a single command.
Further reading
Moving from Ghost CMS to Jekyll
GitHub Pages Basics
Official Jekyll Docs
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse