2

As file count increases, Hexo spends more and more time generating the static HTML files using 'hexo g'. Why does Hexo reconstruct every single '.md' file, instead of limiting itself to the files modified?

My Hexo version is 3.0.1.

TheAcolyte
  • 91
  • 9
CodingMonkey
  • 135
  • 7

3 Answers3

3

It depends on several things, but the major bottlenecks are:

theme not using cache

The author introduced fragment cache last year to cache static parts (header, footer, sidebar).
It is up to the theme author to use it to speed up page generation.
You could try changing to other themes and see if there is any different.

highlight.js language detection

highlight.js will try to auto-detect language in code block if no language is specified since 3.0, which takes considerable time.
Consider using plain and auto_detect option (#1124) and see if there is any different.


It has been mentioned, but not committed, to use an incremental approach in generating the static HTML.

My workflow of using Hexo is:
- hexo serve to preview you update
you modify iteratively in this step
using hexo-livereload saves you actively reloading the page
- hexo generate/hexo deploy to publish your site

leesei
  • 6,020
  • 2
  • 29
  • 51
0

You're explicitly telling Hexo to rebuild every single post. Every time you add a new file, Node will take that much longer to interpret the .md files.

The command 'hexo -g' can be broken into two parts: 'hexo' states that you want Hexo to complete the following command. '-g' is an abbreviation of 'generate'. To use the word 'generate' without any modifiers is to tell Hexo that it should rebuild every post available in the Hexo folder.

In my limited experience, developers only use 'hexo -g' if they are:

  • Performing first-time setup or maintenance
  • Unable to recall the name of their unpublished post

If your computer can churn through .md files in reasonable time, then by all means use 'hexo -g.'

TheAcolyte
  • 91
  • 9
0

one of the easiest to improve performance problem causing components is the markdown stock renderer. fortunately there are lots of alternatives - for example, give hexo-renderer-markdown-it a shot:

  1. clone your hexo install into a separate directory (or just copy your current directory into a different one)
  2. $ npm un hexo-renderer-marked --save
  3. npm i hexo-renderer-markdown-it --save
  4. run "hexo g" in both directories and compare performance
blueberryfields
  • 45,910
  • 28
  • 89
  • 168