hexo-generator-i18n-404
Use AI Translation
When using i18n on Hexo, will display a 404 page if you switch to other languages corresponding to the post. However, this package was born to support i18n 404 pages (hexo-generator-i18n-404).
Main Features
- I18n 404 pages
- I18n default posts
Enable Hexo I18n
First, you need to enable Hexo i18n. Find language
in _config.yml
and add the languages you want to enable.
Here we use zh-tw
, en
, zh-CN
as examples. You can find the supported language codes in the Hexo theme you are using.
1 | # file: _config.yml |
Next, set the post link permalink
and the file name rule new_post_name
. This is for reference only and can be set according to your preference.
1 | # file: _config.yml |
hexo-generator-i18n-404
Install the hexo-generator-i18n-404 package
1 | npm i git+https://github.com/eddy1937/hexo-generator-i18n-404.git |
I18n 404 Pages
Add i18n_404
settings in _config.yml
. You can set it according to each language. When the language setting cannot be found, it will use default. Demo Post
1 | # file: _config.yml |
Name | Description |
---|---|
title |
Post title
Priority order,lang.title > contentPath.title > default.title |
description |
Post description
Priority order,lang.description > contentPath.description > default.description |
contentPath |
Content path, you can use a markdown file as a 404 page
Priority order,lang.contentPath > default.contentPath |
I18n Default Posts
Add i18n_404.usePageOn
to the post to enable default posts. You can use the current post directly in other language versions (existing language posts will not be affected).
As shown below, you can display the zh-tw
post in the zh-CN
language.
1 | # file: your_post.md |
You can also set i18n_404.usePageOn
to all
to use this post in all languages.
1 | lang: zh-tw |
This post only has zh-tw
, en
versions. You can switch the language to Simplified Chinese(简体中文) zh-CN
to check the effect