Skip to content

Instantly share code, notes, and snippets.

@Yinchie
Created July 3, 2018 11:56
Show Gist options
  • Save Yinchie/cb2ecdb321ac9b2f4bc18dc1afcd3ebd to your computer and use it in GitHub Desktop.
Save Yinchie/cb2ecdb321ac9b2f4bc18dc1afcd3ebd to your computer and use it in GitHub Desktop.
How I generate my Jekyll based website. Converting and compressing images and static files to WebP and Brotli after building the site.
#!/bin/bash
cd /home/ghost/WWW-ITCHY
echo "===== Checking for updates ====="
bundle update
echo "===== Build the website ====="
bundle exec jekyll build
# Does not work for directories that has a space in it.
echo "===== Converting images into WebP .webp ====="
for x in `find /var/www/itchy -type f \( -iname \*.jpeg -o -iname \*.jpg -o -iname \*.JPG -o -iname \*.png \)`
do cwebp -quiet -q 80 ${x} -o ${x}.webp;
echo "Converted $x to ${x}.webp"
done
echo "===== Compressing static files into Brotle .br ====="
for x in `find /var/www/itchy -type f \( -iname \*.html -o -iname \*.css -o -iname \*.js \)`
do brotli -v -q 9 -k -f ${x};
echo "Compressed $x to ${x}.br"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment