Blog2018 ≫ Top tips for a faster Jekyll build

Here's how I'm building right now, it helped me find what was slowing my build down:

[jekyll](/wiki/#jekyll) build --incremental --profile --strict_front_matter --limit_posts 10 --watch

You'll find most of these tips elsewhere but I hope I have a new spin on it. So from the docs, --incremental means "only build what has changed" --limit_posts 10 means "only build the newest 10 posts", so only good for development. And probably that is not compatible with --incremental anyway. These get you developing fast, getting quick feedback. The important one for finding the issues is --profile - this will tell you what is taking the time in the build. It will usually be the more complex layout templates, so removing any complexity there will help.

Things I found to be slow were looping through all of site.posts on each blog post (to show latest posts, replies to this post, the parent of this post) so I removed all of them. But still slow...

Another thing I reoved was the scss / sass processing - I now ignore these folders and build this manually when the css changes (not very often). I could be watching and rebuilding this too, but I don't need jekyll to do it.

The biggest villain for me was [jekyll](/wiki/#jekyll)-sitemap - removing this got my site build down from many minutes to (still many) seconds. So remove that, and remove it good. I had to uninstall the gem to get it to take affect.

Also DON'T be tempted to auto generate any content that is not in the _posts folder! I have been looping through my family tree and venues list and creating markdown files that then get built nicely... however because they are not in the _posts folder they all get rebuilt every time. So fix that! It's hard to get your head round (say) a person or a venue that must now be a post in the format but it's worth doing for the speed of building.

I will be back to publish my own solution for a google friendly site map and I will be adding the features back in again if I find they were not hurting the build speed as much as I thought.

⬅️ :: ➡️

Paul Clarke's blog - I live in A small town. Wed + father to 2, I am a full-stack web engineer, and I do mostly js / Node, some ruby, python, php ect ect. I like pubbing, running, eating, home automation and other diy jiggery-pokery, history, genealogy, TV, squirrels, pirates, lego, + TIME TRAVEL.