Jekyll compiling seems WAY too slow

ぐ巨炮叔叔 提交于 2020-01-01 01:17:10

问题


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.


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/26855552/jekyll-compiling-seems-way-too-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!