This is a quick hacky script I wrote in Rust to allow quickly setting up a github pages Jekyll repo to publish with plugins enabled.
By default Github pages blocks plugins, so when the site is built by Github on a push to main the plugins do not run.
This was a problem for my journal site as it has a tag generating plugin I wrote that needs to run during the build phase to generate tag index pages.
To get around this, jekyll build needs to be run locally instead of by Github. The built artifacts are then what should be pushed to the main branch for Github to serve for the site.
This script sets up the repo to achieve this, and can be used each time a new version of the site needs to be published.
First build the project:
cargo build --release
The compiled binary will be in target/release/rust-jekyll-publisher.
Copy or link this binary to the root of the github pages repository that needs to be set up.
Run the following to set up the repository for building locally:
./rust-jekyll-publisher setup
The setup command will:
jekyll build to create the built artifacts in the _site subdir_site to .gitignoresources branch, commit and push there_site subdirmain branch_site subdir)main branch and so does not attempt to build with Jekyll each time something is pushed to mainAfter setup the workflow for publishing updated versions of the Jekyll site should be as follows:
sources branchjekyll build to update the compiled assets in _site_site, make a new commit and push to the main branchThe last two publishing steps above can be performed with:
./rust-jekyll-publisher publish
You will need to commit changes to the source files first or the command will panic.
The benefit of the above is that the source files are still under version control (on the sources branch), and the main branch includes the compiled assets including those generated by plugins.