Here’s a script to help you out when developing with Jekyll. I am very aware that perfectly good minification scripts exist for Jekyll - they are better and more flexible than mine, I’m sure. However, this is just a bash script (it does use some
npm installs), and it’s pretty easy to configure.
I developed this while working on a couple of Jekyll sites (this one included). It is pretty handy.
It minifies your assets, compresses your images, and uploads it all to S3 for you. It can even optionally generate your favicon files for you. This blog (daviseford.com) is run off an EC2 instance that syncs to my S3 bucket every couple of minutes, so all I need to do is upload my changes to S3, and an EC2 cron-job will take care of the rest.
For my dad’s site, parkcenterautomotive.com, I use S3’s static site hosting capability, which makes the whole process extraordinarily simple.
I’ll show you how it looks for Park Center Automotive. All configuration of the script is done at the top of the file.
You can run this script with a
-s flag to automatically install the npm dependencies (Google Closure Compiler, UglifyCSS, and HTML Minifier).
To use this script, create a blank file named
upload.sh file in the root directory of your Jekyll site. Paste the above script into that file and save.
Make sure to configure your options at the top of the script!
Then run the script setup by typing
sh upload.sh -s. Once those dependencies are pulled down, run
sh upload.sh -i to begin compressing and optimizing your images and code.