Use Github Action for Jekyll Static Site
26 Mar 2023I used to use github pages for my jekyll blog post. There was a _site folder which contains the generated artifacts of my site.
I think have the artifacts added to the version control is not a good practice:
- The artifact is genrated, so I have duplications in my repo.
- If I change a template, all the pages in the artifacts will be changed. It will be hard for me to track my changes.
After read about the jekyll document. I decided to use Jekyll-aciton to generate my site with github action. The genrated files will be pushed to gh-pages
branch of my repo. And then I have to change the settings of my repo so it will use that branch for the static website:
The jekyll offical document about jekyll-aciton here is slightly outdated, I have to update my .github/jekyll-action.yml
file with the information from the README of the jekyll-action repo.
Here is the file I am currently using:
The difference between this and the code from the offical website are:
- This uses v2 version of jekyll-action
- The target_branch is set to gh-pages