Decreasing Jekyll build time
I have started using Jekyll for my personal website sometime ago. As I started to add more and more pages the build time for Jekyll started to increase. I started looking for ways to decrease the time taken for build. Here is what I have done so far to improve the build speed
Exclude the files that are not needed
The website repo will contain many files and folders like node modules, Readme, license, etc… that are not part of the final website. Instruct Jekyll to exclude those files. In the _config.yml file, there will be a exclude array. Add the files and folders you want to exclude in the array.
Don’t process assets
Static files such as fonts, images, etc… don’t need to be processed by Jekyll. Jekyll config has an keep_files option where you can define these files or entire assets folder which will be transferred to the final site as it is. Jekyll will not scan for markdown in these directories and will not attempt to process the files thus saving time during build.
Use incremental builds
While running build use the –incremental build flag. This will improve the speed of subsequent builds. As you can see from the screenshot below you can see that the build time decreased from 0.38 sec to 0.16 sec. But without the incremental flag the build speed will remain at ~0.35 sec.
If your site is taking unusually long time to build, then try the –profile flag to understand which page is taking more time to build.
You will get an output like the one above. You can reduce the complex logic in the time taking pages to improve the speed.