Build and deploy
Build a Jekyll site with GH Actions and then publish as a GH Pages site
Topics
Pages
-
Actions for GH Pages
Actions to build a Jekyll site then publish to GH Pages
-
Generic steps
Use a Ruby action to set up Ruby and gems, then build, and deploy with a generic deploy step
- Jekyll Actions action
- Jekyll in a container
Content
Samples
In the examples in this section, there is a step to build the site with Jekyll and then a final step to serve the commit the _site
directory to the gh-pages
branch using an action. This keeps your source code on the main branch separate from the output site on the gh-pages
branch.
After you have a workflow building successful, you can configure your repo’s Settings to serve your gh-pages
branch as a GitHub Pages site.
Why use GitHub Actions for Jekyll?
Note that if you set up a Jekyll site on GitHub, such as with a config and a homepage, GitHub can build the site and serve it for you. No GitHub Actions needed. And only one branch is needed.
That approach without GitHub Actions is much simpler. The downside is that you are forced to use the plugins and Jekyll version set up by GitHub. And you can’t mix in Node or Python or whatever in your build flow. With GitHub Actions, you get control of that. Plus better logging on failed builds.
Related Cookbook sections
- GH Pages Actions page in this Jekyll section.
- Deploy GH Pages as a more generic section which could still be used for Jekyll.
- Jekyll container page.
Demo site
See my Jekyll GH Actions Quickstart template project which demonstrates how to build a minimal site. It has a GH Actions flow which sets up Jekyll and runs GH Pages deploy in the last step.
- Live demo website.