I'm building a site with Jekyll for the first time. I'm loving it so far; my only problem is the exceedingly long build times. Right now, when I run jekyll build
, it takes about 30 seconds to generate the site.
30 seconds might not seem like a lot, but at the moment, the entire site only has ONE post, 8 includes, 8 layouts, and 2 small plugins. I haven't abused liquid tags to my knowledge, and if I remove the plugins, it still takes just as long.
When searching for an answer, all I can find are people who have huge blogs with hundreds of posts. Since I only have one post, that's obviously not the issue - there's something else going on here to make it take so long.
Here is my site's github repository: https://github.com/keithpickering/kpd/
My questions are as follows:
What are some possible reasons for Jekyll building so slowly when it doesn't have all that much to build?
If Jekyll is just inherently slow, is there a simple way to compile my CSS and JS separately, leaving Jekyll to deal with just the markup? Right now I have Jekyll ignore my "css" and "js" folders, instead having Grunt minify, prefix, and compile those files automatically. I've also never used Grunt before so I have no idea if this is some sort of absurdly hacky solution that I'm using.
Thanks for the help!
EDIT: Should've mentioned this sooner, but I'm on Windows 8.1 x64. I'm beginning to think Jekyll just has shaky support for Windows.
I ran into a similar problem, but luckily found the reason and a solution:
My jekyll setup wasn't using any plugins, no complicated liquid tags, only contained 3 sample posts and nothing else. But building the site still took 6 seconds on average.
Only when I removed everthing in the directory step by step I found out what was causing the long build times: the node_modules
folder.
You can exclude the node_modules
directory from the jekyll conversion by putting the following in _config.yml
:
exclude: [node_modules]
Or:
exclude:
- node_modules
More information about exclude
can be found in the jekyll documentation.
You could render only the latest post:
jekyll serve --watch --limit_posts 1
It is almost twice faster, in my case.
UPDATE:
Even better, rebuild only what is changed:
jekyll serve --incremental
Up to 30 times faster in my case! Unfortunately, works only for blog posts and some pages.
I had super slow Jekyll build times when using the octopress-minify-html
gem to minify my html.
To expedite build times in development, I added minify_html: false
to my _config.yml
file.
This one change brought build times from over 60 seconds to ~1 second (!).
I've benchmarked a new jekyll site and your repository with Benchmark. Same time, around 5 seconds.
The problem is somewhere else. I think your ruby / gems install has a problem. Reinstall.
On the assets side (js, css) Jekyll is good at (sass, coffeescript) and you can use jekyll assets for minification and other optimization things. Performance overhead is not a problem with this solution.
Same for Grunt/Gulp but this implies that you also manage a node.js installation.
What are some possible reasons for Jekyll building so slowly when it doesn't have all that much to build?
In my case, switching from ruby 1.9.3-p448 to 2.1.3 made a huge difference: regenerating a single file took several seconds in 1.9.3, almost instantaneous in 2.1.3.
My setup was: Mac OS X 10.10, 50 posts and several tiny plugins, jekyll 2.4.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With