# 13 seconds build time per page

**URL:** <https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007>\
**Category:** Help\
**Created:** [February 8, 2023, 3:35pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007 "2023-02-08T15:35:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Natro](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Natro](https://talk.jekyllrb.com/u/Natro)\
**Post date:** [February 8, 2023, 3:35pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/1 "2023-02-08T15:35:04Z")

</div>

Hey!

I am complete beginner to Jekyll and I have been tasked to create documentation for our big C# Framework. We decided to go for Just The Docs ([GitHub - just-the-docs/just-the-docs: A modern, high customizable, responsive Jekyll theme for documentation with built-in search.](https://github.com/just-the-docs/just-the-docs)) theme as built-in search was a must and it looked very minimalistic and nice.

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:

1. Is there a way to decrease this build time?
2. Is there a way to cache built site so the next built just builds the changed files?
3. What information should I provide you with regarding my project?

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [February 8, 2023, 5:48pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/2 "2023-02-08T17:48:11Z")

</div>

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

## 🙋 Questions

- What version of Jekyll are you using?
- What version of Ruby are you using?
- Are you using any plugins?
- Are you using incremental builds?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [February 8, 2023, 10:40pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/3 "2023-02-08T22:40:45Z")

</div>

you could try doing `jekyll b --profile` and it should show you some info on what is taking so long.

There is also an incremental command to build just the pages that changed but it is still experimental and may not work properly in all cases.

> **[Configuration Options](https://jekyllrb.com/docs/configuration/options/)**
>
> The tables below list the available settings for Jekyll, and the various options (specified in the configuration file) and flags (specified on the command-line) that control them.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [February 9, 2023, 7:18am UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/4 "2023-02-09T07:18:14Z")

</div>

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.

A

---

<div class="post-metadata">

**Author:** ![Natro](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Natro](https://talk.jekyllrb.com/u/Natro)\
**Post date:** [February 9, 2023, 8:52am UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/5 "2023-02-09T08:52:09Z")

</div>

Thank you all for answers.

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.

```auto
Rendering: docs/(FRAMEWORK)-api/Generated/(REDACTED).(REDACTED_OTHER_FRAMEWORK).BLEServices/ASHAService/ASHAAudioStatus.md
Pre-Render Hooks: docs/(FRAMEWORK)-api/Generated/(REDACTED).(REDACTED_OTHER_FRAMEWORK).BLEServices/ASHAService/ASHAAudioStatus.md
Rendering Markup: docs/(FRAMEWORK)-api/Generated/(REDACTED).(REDACTED_OTHER_FRAMEWORK).BLEServices/ASHAService/ASHAAudioStatus.md
Post-Convert Hooks: docs/(FRAMEWORK)-api/Generated/(REDACTED).(REDACTED_OTHER_FRAMEWORK).BLEServices/ASHAService/ASHAAudioStatus.md
Rendering Layout: docs/(FRAMEWORK)-api/Generated/(REDACTED).(REDACTED_OTHER_FRAMEWORK).BLEServices/ASHAService/ASHAAudioStatus.md

```

I am providing you a repository.  
[Natromitus/jekyll-doc-tsl2 (github.com)](https://github.com/Natromitus/jekyll-doc-tsl2)

I had to do few things so I won’t get into trouble:

1. I had to do some patchwork censoring so it isn’t plainly obvious what the frameworks are.
2. 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.

---

<div class="post-metadata">

**Author:** ![jhvanderschee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jhvanderschee/32/583_2.png) [@jhvanderschee](https://talk.jekyllrb.com/u/jhvanderschee)\
**Post date:** [February 9, 2023, 1:33pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/6 "2023-02-09T13:33:38Z")

</div>

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 %}`

> <https://github.com/just-the-docs/just-the-docs/blob/main/_includes/nav.html>

The include nav.html is used in the sidebar.

> <https://github.com/just-the-docs/just-the-docs/blob/main/_includes/components/sidebar.html>

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

```auto
---
layout: default
title: (REDACTED).(REDACTED_OTHER_FRAMEWORK)
grand_parent: 
parent: (REDACTED_FRAMEWORK) API
has_children: True
permalink: /(REDACTED_FRAMEWORK)-api/ReSoundSETTestwareTestCaseActionsRatatoskAssembly
---

```

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.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [February 9, 2023, 5:14pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/7 "2023-02-09T17:14:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Natro](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@Natro](https://talk.jekyllrb.com/u/Natro)\
**Post date:** [February 9, 2023, 5:15pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/8 "2023-02-09T17:15:56Z")

</div>

Yes most likely got disposed during censorship, sorry about it ☹

Ah, that’s a shame I really liked the theme and the documentation was almost done. I guess I am jumping ship.

Thank you very much guys.

---

<div class="post-metadata">

**Author:** ![pdmosses](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pdmosses/32/4764_2.png) [@pdmosses](https://talk.jekyllrb.com/u/pdmosses)\
**Post date:** [April 10, 2023, 3:30pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/9 "2023-04-10T15:30:15Z")

</div>

@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):

```auto
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:

```auto
    just-the-docs (0.3.3)

```

That version of the theme was released in October 2020 (see the theme repo at [GitHub - just-the-docs/just-the-docs: A modern, high customizable, responsive Jekyll theme for documentation with built-in search.](https://github.com/just-the-docs/just-the-docs)). A significantly improved version (0.4.0) was released on Feb 6. That was before your initial post – but you’re using the theme _gem_, so you don’t get new releases unless you run `bundle update` (or delete `Gemfile.lock`).\[1\]

```auto
bundle update
bundle exec jekyll build --profile

```

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.

> [@jhvanderschee](#):
>
> 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).

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.

> [@ashmaroli](#):
>
> 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.

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?

* * *

1. Using `remote_theme: just-the-docs/just-the-docs` instead of `theme: just-the-docs` ensures that you always get the latest theme updates without updating the bundle.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [April 10, 2023, 3:50pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/10 "2023-04-10T15:50:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jhvanderschee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jhvanderschee/32/583_2.png) [@jhvanderschee](https://talk.jekyllrb.com/u/jhvanderschee)\
**Post date:** [April 10, 2023, 7:54pm UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/11 "2023-04-10T19:54:39Z")

</div>

> [@jhvanderschee](#):
>
> Having frontmatter like this is terrible from a maintenance POV.

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.

---

<div class="post-metadata">

**Author:** ![pdmosses](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/pdmosses/32/4764_2.png) [@pdmosses](https://talk.jekyllrb.com/u/pdmosses)\
**Post date:** [April 11, 2023, 8:34am UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/12 "2023-04-11T08:34:33Z")

</div>

> [@Natro](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![jhvanderschee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jhvanderschee/32/583_2.png) [@jhvanderschee](https://talk.jekyllrb.com/u/jhvanderschee)\
**Post date:** [April 11, 2023, 8:54am UTC](https://talk.jekyllrb.com/t/13-seconds-build-time-per-page/8007/13 "2023-04-11T08:54:15Z")

</div>

> [@pdmosses](#):
>
> Presumably the front matter of all those files is generated too.

I am not sure if that is the right assumption. I am no expert in this market (segment). You are probably right.
