Hexo Blog Build Performance Optimization

This article introduces Hexo blog build performance optimization, including its advantages, implementation details, and related resources. These steps can help improve the efficiency of Hexo blog build performance optimization.

Oct 23, 2021 · 1 min read · 209 Words · -Views -Comments · Programming
🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

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

  1. Remove certain plugins/features

    • category
    • baidu sitemap
  2. Algolia

    • Remove certain indexing fields: gallery, photo, excerpt, slug
  3. 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
  4. 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.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover