Sorry for breaking this post up into pieces but apparently I cannot post more than two links in a single post. Not sure what problem this solves…
I’m on Jekyll 3.9.0 (which is dictated by github-pages 215). I’m using a remote theme jekyll-rtd-theme that I really like the looks of.
Currently my site consists of 221 markdown files (or 283 if to include the README.md for jekyll-readme-index) and about 30 directories and subdirectories with those files.
The site takes more than 2 minutes to build, which I think is a rather long time.
Enabling incremental regeneration does not make any difference to the build time. So the problem does not seem to be there. Incidentally, it creates .jekyll-metadata file that balloons in size even when there are tiny changes (1 md file added). In the last few builds it went from 0.7 → 1.4 → 2.0 → 2.7 → 3.6MB. At this rate this file will be larger than the whole website soon…
Back to the build time, I’ve tried with the liquid profiler and below are the results, I’m only listing the top entries that took longer than a second:
Finally templates/_toctree.liquid that include’s itself in a loop. Presumably each include counts as 1 in the profiler’s output. So 226 include’s, quite a few but not some massive number, and if I understand the profiler output correctly close to a second per each include of _toctree.liquid.
1 second seems quite a long time. I’ve just started with Jekyll and I’m unfamiliar with Liquid so can someone help identify the slow bit, please?
The slow bit is the loops used in that theme. Didn’t dig into it too deeply, but it appears to be looping through files in various directories to create the sidebar and other parts of the site.
These sorts of loops along with looping over all posts/pages are notoriously costly in Jekyll-land. The more files you add the longer your build times will become.
Thanks for your replies. I tinkered with that theme, got rid of GitHub Pages and managed to upgrade to Jekyll 4.2, and that cut the build time down to 60 seconds, so reduced by almost half.
I also wanted to try with Liquid 5 and see what that does to performance but unfortunately Jekyll doesn’t allow such upgrade and it seems that in Ruby world there is no straightforward way to override the dependency version restrictions.
What I’m planning to do next is to get rid of this awful Liquid thing used for generating the sidebar in the theme anyway and try with JavaScript instead.
I thought I could use JavaScript magic in Liquid templates because I came across a {% javascript %} or something like that mentioned somewhere but it must have been some random custom tag and I didn’t know anything about custom tags at the time.
That however put me on the right path and I rewrote the sidebar generation and made it into a Ruby plugin which reduced the build time to a mere 7 seconds! That’s more like it