21
votes

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:

  1. What are some possible reasons for Jekyll building so slowly when it doesn't have all that much to build?

  2. 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.

5
A repository address is necessary in your case.David Jacquel
What is the format: Markdown, Textile, HTML? Which are the versions of the converters (e.g. Jekyll, RedCloth, RedCarpet, Kramdown, etc.etc.)? What do the plugins do? For instance, with the old RedCloth, my Jekyll builds were pretty slow, but with the new version, they are almost instantaneous. If a plugin does something very slowly, that also affects the speed. Etc.etc.Rudy Velthuis
@DavidJacquel Here's my repo, sorry: github.com/keithpickering/kpdKeith Pickering
@RudyVelthuis I'm using Markdown for the single post I have. Jekyll version is 2.4.0. The plugins have to do with creating category pages, but like I said, it's equally slow with the plugins removed. I have no idea what RedCloth, RedCarpet, or Kramdown are :pKeith Pickering
RedCloth etc. are markup language converters. RedCloth for Textile, RedCarpet etc. for Markdown. Are you using a highlighter? If yes, and it is pygments, find out which version it is.Rudy Velthuis

5 Answers

45
votes

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.

9
votes

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.

2
votes

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 (!).

1
votes

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.

1
votes

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.