If you're looking for a simple and flexible way to support multiple languages in your Hexo blog—without switching themes or purchasing new domain names—this post is for you.

In this tutorial, I’ll walk you through the easiest method to implement internationalization (i18n) in Hexo, using Chinese and English as examples. This method works regardless of what Hexo theme you're using.

🔔 Note: This approach does not rely on auto-translation. You’ll need to maintain separate .md files for each language—so if you support 2 languages, you’ll maintain 2 versions of each post.


🎯 Goal

Add a language switch button to your blog’s homepage. Clicking it will redirect users to the version of the site in another language—without needing to purchase a new domain.


🛠️ Step-by-Step Implementation

1. Duplicate Your Blog Folder

Assume your existing Hexo project folder is named hexo, and contains your default language (e.g., Chinese). Now create a new sibling folder hexo-en for English content.

Your project structure should look like this:

/Blog
  ├── hexo      # Original site (Chinese)
  └── hexo-en   # English version

Do not copy the node_modules folder—everything else should be copied.


2. Modify _config.yml for Each Version

In both hexo and hexo-en, open _config.yml and make the following changes:

  • Set the language field appropriately:

    • hexo: language: zh-CN
    • hexo-en: language: en
  • Set the root and url fields:

    • hexo: root: /, url: https://yourdomain.com
    • hexo-en: root: /en/, url: https://yourdomain.com/en

📷 Screenshots showing these changes are helpful for visual reference.


3. Update the Theme Menu to Add Language Switch

Most Hexo themes have a menu section in the config file (or _config.yml). Add a new menu item that links to the other language version.

In hexo (Chinese), the button should say "English" and link to /en/.

In hexo-en (English), the button should say "中文" and link to /.

⚠️ Warning: If you’re using GitHub Pages, direct jumps to yourname.github.io/en may result in a 404 error. But redirects to custom domains like yourdomain.com/en typically work.


4. Install Dependencies

In your new hexo-en folder, run:

npm install

5. Deploy Script for Both Versions

Since both folders generate static sites separately, we’ll combine their outputs during deployment.

Here’s an example shell command:

cd /d/Blog/hexo && hexo clean && hexo g \
&& cd /d/Blog/hexo-en && hexo clean && hexo g \
&& cd /d/Blog/hexo \
&& cp -r /d/Blog/hexo-en/public/. /d/Blog/hexo/public/en/ \
&& hexo d

This ensures:

  • Both sites are generated
  • English output is copied into the /en/ directory of the main site
  • Everything is deployed at once

🎉 That's It!

You now have a bilingual Hexo blog, with a simple switch button and no need for domain juggling. The only downside: clicking the language switch redirects to a new page rather than dynamically updating it. But for most blogs, that’s totally fine.


🧨 Common Error: Spawn Failed

Sometimes after editing and trying to deploy, you might see:

Error: Spawn Failed

This often stems from issues with the .deploy_git folder, which Hexo uses internally to push to GitHub.

✅ Fix:

  1. Delete the .deploy_git folder.
  2. Then run:
git config --global core.autocrlf false
  1. Finally, regenerate and deploy again using:
hexo clean && hexo g && hexo d

❗ If you're using absolute paths in your deployment script, make sure .deploy_git isn't accidentally created in the wrong project folder (e.g., hexo-en).

Also, sometimes network issues may cause this error. A quick retry after deleting .deploy_git usually solves it.


🙌 Final Thoughts

This method is lightweight, doesn't depend on any Hexo plugin, and is highly customizable. While maintaining multiple language versions manually takes more effort, it gives you full control over your content.