I went to writing articles and everything was working fine - until I wrote a script that generates markdown files from our library. I now have over 2000 markdown files of a long documentation with a lot of nesting and references to each other. (Think Enterprise size library). I checked how long does it take for one page to load and it’s about 13.5 seconds. If you do the math it will take me few hours to build the whole documentation.
Our old solution using DocFX built time as a whole was around 7 minutes. There has to be a way to make it at least come a bit close to that I suppose.
So I have few questions:
Is there a way to decrease this build time?
Is there a way to cache built site so the next built just builds the changed files?
What information should I provide you with regarding my project?
I checked how long does it take for one page to load and it’s about 13.5 seconds.
To ensure I fully understand the issue, you are not saying it takes 13.5 seconds per page to load but 13.5 seconds to build, correct?
I’ll assume that is what you mean for the time being.
There are many reasons it takes a long time for your site to build, but as you say, this does seem quite lengthy. There are thousands of themes for Jekyll. I do not know Just The Docs, but I have heard of others using it.
Share your repo, if possible
The best and easiest way for any of us to help you here is to share the repo if it is public so we can take a look at it, maybe clone it and see what build issues there may be.
Temporarily disable search functionality
The first thing I might do is look at your _config.yml file. I looked at the Just The Docs file, which contains many configurations. While I am not saying “do not use this feature,” you might be able to debug at least what is causing the slowness. To start, I would change search_enabled: true to search_enabled: false and rebuild the site to see if there is a noticeable impact.
Hi,
13-seconds per page is definitely appalling. Are you by any chance using Jekyll 3.9 or older? If yes, could you try with Jekyll 4?
However, if you’re using Jekyll 4.3.1, try updating to v4.3.2. If it’s still this slow with v4.3.2, I’d definitely like to clone your repository and see what’s the reason.
I am actually being serious when I say ~13s per page (post? / markdown file). So the build would be in hours.
Jekyll version: 4.2.2
Ruby version: 3.1.2p20
Plugins: jekyll-feed
Incremental builds: I have not been using incremental build - will start to do that from now.
I have tried turning off the searching options but there was no difference that I could notice.
I am building my project with: bundle exec jekyll serve --verbose --livereload --incremental
Reading of files happens fast but rendering is what is slowing the process down.
When running the above mentioned command below lines last around ~13s, then it moved to next file.
I had to do few things so I won’t get into trouble:
I had to do some patchwork censoring so it isn’t plainly obvious what the frameworks are.
I had to delete a lot of files from the repository - resulting now in much faster build.
articles disclosing internal documentation
around 2000 markdown files generated from Framework used for development
images
I noticed that after deleting a lot of pages a render time per markdown file went down by half. Less markdown files there are faster the time is per markdown file.
Here you can see the issue: it iterates over all your content in all your pages. It probably does that also for the search, but I did not look into that.
{% include nav.html pages=collection key=collection_key %}
The include nav.html is used in the sidebar.
The code is not written with performance in mind, as you can see above. Some very poor choices have been made in building this theme. Having frontmatter like this is terrible from a maintenance POV. The performance of this theme could be fixed by having an autocollapsing menu that gets its active state from javascript. In that case it can be generated once instead of 2000 times (the amount of pages you have).
Also, I would not use Jekyll, but Hugo for this purpose (generating a big documentation website). If you want me to port it for you, contact me on joost@vdschee.nl.
Thank you for providing a link to a public repository, @Natro. However, I was unable to find a file with ASHAService in its relative_path. I’m guessing that it probably got thrown out during the censorship.
Since it has been pointed out that there are bits of non-performant bits in the theme, you’re either better off creating a custom theme from scratch or jump the ship and switch to another static-site-generator such as Hugo which is known for its fast build times.
@Natro thanks for the link to the cut-down repository. You wrote:
I checked how long does it take for one page to load and it’s about 13.5 seconds.
I noticed that after deleting a lot of pages a render time per markdown file went down by half.
I’ve profiled the provided repo (running on a MacBook Air M2):
bundle install
bundle exec jekyll build --profile
It took 420 seconds. The repo has 559 markdown files with front matter, so that was under one second per page. Perhaps you were running on a significantly slower platform?
Each page includes the entire navigation hierarchy, so when you double the number of pages, the size of the HTML for the navigation on each page also doubles. I guess your original 2500+ pages would take at least an hour on my platform, which is indeed unacceptably slow.
However, I noticed that your Gemfile.lock includes the line:
Now building your 559 pages takes 42 seconds on my platform: a 10x speedup! Perhaps I’d build your original 2500+ pages in about 10 minutes.
The code shown by @jhvanderschee is from v0.4.0 of the theme. It was written with performance somewhat more in mind than the corresponding code in v0.3.3 was. However, to provide acceptable speed for building sites with thousands of pages, the navigation would surely need to be generated just once, as @jhvanderschee suggested.
BTW, I don’t understand @jhvanderschee’s remark about front matter (which is presumably referring to @Natro’s repo, not to the theme code). It doesn’t seem at all relevant to the slowness of the build.
I’m surprised to see one of the main Jekyll developers suggesting to create a custom theme, or switch to a competing SSG, for building a site with a few thousand pages! Isn’t Jekyll normally used to build much larger sites with the existing themes?
Jekyll can be used to generate a large site performantly, especially with Jekyll 4.x, but it cannot be as fast as an SSG written using Golang or Python 3, etc Moreover, performance in Jekyll is subject to how Liquid code is written.
The front matter has parent and grand parent and children variables. What if you want to move something, or a add a child? Then you need to update quite a lot.
Presumably the front matter of all those files is generated too. If you move something, you simply regenerate the files, so there’s never any need to update the front matter manually.
Just the Docs is currently limited to 3-level navigation, but we’re aiming to support unlimited depth, specifying only the parent of each node. The current need to specify also the grandparent and children variables can indeed make maintenance tedious.