Hexo Blog Automated Translation Solution Based on Large Language Models

该项目已在 GitHub 开源。您可以访问 Tokisaki-Galaxy/hexo-translate-llm 获取更多信息。

跨语言的信息传播在数字化时代愈发重要。手动翻译文章不仅耗时,也难以保证更新频率。Hexo LLM Translate 插件为此提供了自动化解决方案。它利用大语言模型(LLM)实现博客内容的高质量翻译。

核心特性

智能双语切换提升了读者的阅读体验。插件会识别浏览器的语言偏好。读者无需手动点击即可阅读对应版本。

缓存机制保障了翻译效率。插件通过内容哈希识别变更。只有在正文或标题变动时才会触发接口调用。这有效降低了 API 的使用成本。

多端同步支持远程数据库。通过 Neon PostgreSQL,不同设备间的构建缓存可以实时共享。(可选)

稳定性是插件设计的核心。内置限流器防止并发过高导致接口熔断。自动重试机制能有效应对网络波动。

SEO 优化确保了搜索权重的留存。翻译后的内容直接注入 HTML 结构。搜索引擎可以完整抓取双语信息。Hexo 特有的标签也得到了妥善保护,避免了页面结构的破坏。

对于不想被翻译的文章,可以通过 Front-matter 设置 no_translate: true 来排除在外。

快速上手

安装插件

在 Hexo 根目录下执行安装指令:

1
npm install hexo-translate-llm

配置参数

_config.yml 中加入以下配置。建议选用性价比更高的模型:

1
2
3
4
5
6
llm_translation:
enable: true
model: deepseek-ai/DeepSeek-V3.2
endpoint: https://api.siliconflow.cn/v1/chat/completions
max_concurrency: 4
single_timeout: 120

如果不想使用远程数据库,可以跳过 Neon PostgreSQL 的配置步骤。插件会自动使用本地缓存。

安全设置

本项目通过环境变量管理敏感信息。

Vercel 部署

在 Vercel 仪表盘的项目设置中,添加LLM_API_KEY环境变量。
设置 Storage 连接,连接到neon PostgreSQL数据库。vercel会自动注入DATABASE_URL环境变量。

本地构建

在根目录创建 .env 文件:

1
2
LLM_API_KEY=您的密钥
DATABASE_URL=数据库连接地址

使用技巧

特定文章可以排除在翻译范围之外。只需在 Front-matter 中设置 no_translate: true。插件会自动同步页面的 title 标签,确保浏览器标签页的语言一致性。

This project has been open-sourced on GitHub. You can visit Tokisaki-Galaxy/hexo-translate-llm for more information.

Cross-language information dissemination is becoming increasingly important in the digital age. Manually translating articles is not only time-consuming but also difficult to maintain frequent updates. The Hexo LLM Translate plugin provides an automated solution for this. It utilizes large language models (LLMs) to achieve high-quality translation of blog content.

Core Features

Intelligent bilingual switching enhances the reader’s experience. The plugin identifies the browser’s language preference. Readers don’t need to click manually to read the corresponding version.

The caching mechanism ensures translation efficiency. The plugin identifies changes through content hashing. It only triggers API calls when the body or title changes. This effectively reduces API usage costs.

Multi-device synchronization supports remote databases. Through Neon PostgreSQL, build caches can be shared in real-time between different devices. (Optional)

Stability is at the core of the plugin’s design. A built-in rate limiter prevents circuit breaking due to high concurrency. An automatic retry mechanism effectively handles network fluctuations.

SEO optimization ensures search engine weight is retained. Translated content is directly injected into the HTML structure. Search engines can fully crawl bilingual information. Hexo-specific tags are also properly protected, avoiding damage to the page structure.

For articles you do not want to be translated, you can exclude them by setting no_translate: true in the Front-matter.

Quick Start

Installing the Plugin

Execute the installation command in the Hexo root directory:

1
npm install hexo-translate-llm

Configuration Parameters

Add the following configuration to _config.yml. It is recommended to choose a more cost-effective model:

1
2
3
4
5
6
llm_translation:
enable: true
model: deepseek-ai/DeepSeek-V3.2
endpoint: https://api.siliconflow.cn/v1/chat/completions
max_concurrency: 4
single_timeout: 120

If you don’t want to use a remote database, you can skip the Neon PostgreSQL configuration steps. The plugin will automatically use the local cache.

Security Settings

This project manages sensitive information through environment variables.

Vercel Deployment

In the project settings on the Vercel dashboard, add the LLM_API_KEY environment variable.
Set up a Storage connection to connect to the neon PostgreSQL database. Vercel will automatically inject the DATABASE_URL environment variable.

Local Build

Create a .env file in the root directory:

1
2
LLM_API_KEY=Your Key
DATABASE_URL=Database Connection URL

Usage Tips

Specific articles can be excluded from translation. Simply set no_translate: true in the Front-matter. The plugin will automatically synchronize the page’s title tag, ensuring language consistency in the browser tab.


Hexo Blog Automated Translation Solution Based on Large Language Models
https://tokisaki.top/blog/hexo-translate-llm/
作者
Tokisaki Galaxy
发布于
2026年1月5日
许可协议