Speed up jekyll site generation with rsync
Jekyll doesn’t support incremental generation so if your site contains loads of static assets like image, audios,.. jekyll is gonna stroke everytime you re-generate your site by deleting and re-generate/re-coppying everything. This little trick below will help you speeding up jekyll generation process by skipping all the static assets that you specified, until jekyll comes up with a better solution.
Rename your static asset folder with underscore in front. jekyll is going to ignore this when generating site. Assume this folder is named
images. You will rename it to be
_config.yml, add the line below. This line basically means that when re-generating, the folder called
imagesin generated folder is not getting touched.
- Keeping in the source and generated folder in sync with a little plugin and rsync. Created a file name
_pluginsfolder with the content below.
module Jekyll class RsyncImageGenerator < Generator def generate(site) system('mkdir -p _site'); system('rsync --archive --delete _img/ _site/img/'); end end end
From now on, jekyll will ignore the
_images folder in your source and
_sites folder when generating your site. We keep it in sync by using rsync, which is much better/faster than delete/copy process jekyll is using.
Github Pages does support jekyll gems now but it’s kinda limited.