Hexo Blog Build Performance Optimization
Took advantage of the weekend to optimize my personal blog’s build performance. Previously each build took 10+ minutes, after optimization it takes 6 minutes. If we exclude search indexing, deploying just the blog to VPS takes only 3+ minutes. Here’s a summary of the optimization items.
Optimization Items
Remove certain plugins/features
- category
- baidu sitemap
Algolia
- Remove certain indexing fields: gallery, photo, excerpt, slug
CI process optimization
- Cache hexo db.json/node_modules
- Automatically cancel previously running workflows using
cancel-workflow-action
- Update Algolia indexing after VPS deployment, since it doesn’t affect blog browsing, only search hit rates
Upgrade hexo to v5, cli to v4
For specific configurations, you can check the source code at https://github.com/alanhe421/alanhe421.github.io
Extended Discussion
Regarding the issue of slow builds when Hexo has many articles, there’s an official issue discussing this. The optimization solutions are similar to what I implemented above. If the performance is still unacceptable after optimization, the only option would be to abandon using static blogs.
Slow static blog builds due to many articles/plugins is not HexoJS’s fault - this is a common problem across static site generators.
Final Thoughts
So, if in the future the number of articles grows to the point where builds remain this slow, I might have to switch to a dynamic blog platform.