22

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.

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
Keith Pickering
  • 696
  • 10
  • 24
  • A repository address is necessary in your case. – David Jacquel Nov 11 '14 at 01:54
  • 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 Nov 11 '14 at 11:17
  • @DavidJacquel Here's my repo, sorry: https://github.com/keithpickering/kpd/ – Keith Pickering Nov 11 '14 at 17:16
  • @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 :p – Keith Pickering Nov 11 '14 at 17:21
  • 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 Nov 12 '14 at 01:27
  • No highlighter yet, I wanted to keep it pretty simple to start. Also, I did a little research and I do have RedCarpet - I wasn't aware of it since I just used RubyInstaller to install everything. – Keith Pickering Nov 12 '14 at 02:52

5 Answers5

46

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.

10

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.

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
  • 2
    ```jekyll serve --incremental``` - can't believe, why I didn't look at this issue earlier, my site was re-generating very slow (about 35 seconds), now it's about second. – Alex Golovin Jul 23 '19 at 09:39
2

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

duhaime
  • 25,611
  • 17
  • 169
  • 224
1

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.

David Jacquel
  • 51,670
  • 6
  • 121
  • 147
  • Thanks for the reply, I'll try reinstalling Ruby and report back. Jekyll Assets seems pretty cool; would you say there's any benefit to using it instead of Grunt for minification/etc? – Keith Pickering Nov 11 '14 at 19:53
  • Just uninstalled and reinstalled Ruby along with all of my gems. I also updated Jekyll to the most recent version. Same issue as before, everything works but it's just as slow. – Keith Pickering Nov 11 '14 at 23:33
  • Tried compiling on a separate, much more powerful computer with Windows 10, the latest version of Ruby, and the latest version of Jekyll. Takes just as much time. I think Ruby and Jekyll are just absurdly slow on Windows, which is a shame considering it's what almost every person uses. – Keith Pickering Nov 12 '14 at 21:49
  • Sorry for you. That's true that windows is not always easy with some open web technologies. I'm sure that you can enjoy a dual boot with Ubuntu 14.04. Take some time to learn it and you'll love it. – David Jacquel Nov 12 '14 at 22:00
  • 3
    I've used Ubuntu before, and I don't have anything against it, but I'd rather be able to use my OS of choice for development. – Keith Pickering Nov 12 '14 at 22:33
  • Yep ! Hope You'll find a solution to this problem because I find Jekyll is a really good concept. – David Jacquel Nov 12 '14 at 23:25
  • I wonder if there's a way to run my text editor and everything else in Windows while running Ruby in a Ubuntu virtual machine. Probably not worth the effort if it's even possible. – Keith Pickering Nov 13 '14 at 03:09
  • Yo Keith ! I don't know what is your day to day work but if you don't need visual studio and photoshop, you can definitely switch to Linux. We have plenty nice IDEs from Sublime to JetBrain rockets. Be Geek ! – David Jacquel Nov 13 '14 at 12:30
  • And Jumping on Ubuntu is easy and there is a good SO site called [AskUbuntu](http://askubuntu.com/) – David Jacquel Nov 13 '14 at 12:32
  • Guys, I understand that Ubuntu is faster, but I don't use my PCs for just work. I highly prefer Windows for my day-to-day tasks. Also, I do need Photoshop. I'm thinking about dual booting OSX Yosemite to solve this problem, but I think the problem at large is that this entire language is just broken in Windows. I appreciate the responses, but "switch to Linux" is not a realistic answer for me. – Keith Pickering Nov 13 '14 at 16:42
  • Sorry not `switch to linux`, better `dual boot to linux` – David Jacquel Nov 13 '14 at 18:25
1

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.

ento
  • 5,801
  • 6
  • 51
  • 69
  • I've tried multiple versions of Ruby on two machines. There's just something about Windows that bottlenecks everything having to do with Ruby. – Keith Pickering Nov 18 '14 at 09:53