Hexo 创建中英文博客

自从来到亚马逊工作,接触英文和外国同事比较多。锻炼使用英语的需求越来越大。而且为了和国际接轨,我决定创建自己的英文博客。

两座由同一套积木搭成的中英文博客屋沿不同轨道部署,并由一座双向桥连接

步骤

以中文博客为模版,创建英文博客。

1
cp -r Hexo HexoEn

删除HexoEn中没用的中文博文和资源。

在Github创建一个新repo:“en”.

修改HexoEn _config.yml配置文件。注意部署分支为gh-pages, 这个GitHub默认的pages分支,如果不同的话,需要去repo的Setting->Pages配置一下你自定义的分支:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
language: 
- en
deploy:
type: git
repo: git@github.com:YoungForest/en.git
branch: gh-pages
theme_config:
menu:
home: / || fa fa-home
about: /about/ || fa fa-user
tags: /tags/ || fa fa-tags
categories: /categories/ || fa fa-th
archives: /archives/ || fa fa-archive
中文: https://youngforest.github.io || fa fa-language # 图标可以去该网站搜索:https://fontawesome.com/v4.7/icons/

中文Hexo _config.yml配置文件:

1
2
3
4
5
6
7
8
9
10
11
language: 
- zh-CN
- en
theme_config:
menu:
home: / || fa fa-home
about: /about/ || fa fa-user
tags: /tags/ || fa fa-tags
categories: /categories/ || fa fa-th
archives: /archives/ || fa fa-archive
English: https://youngforest.github.io/en/ || fa fa-globe

这样中英文博客就可以在Menu互相外链了。

部署博客,看看效果如何。

1
hexo generate -d

把HexoEn也推到远端,做保存和同步。注意,这里和deploy用的是同一个repo, 但是不同的分支。

1
2
3
git remote remove origin
git remote add origin git@github.com:YoungForest/en.git
git push -u origin master

最后的效果

中文博客:https://youngforest.github.io
英文博客:https://youngforest.github.io/en/

历史评论3
只读归档

由 Disqus 迁移并静态保存;新的讨论请在下方继续。

  1. Lucas
    博主你好,最近我也在搞英文博客,使用的方法和你的类似,但是我在menu点击切换语言的外链的时候并不会重新刷新网页,而只是更新了内容栏里的内容,可以请教一下是什么原因吗,这是我的博客地址https://lucas-hao.github.io...
    1. YoungForest
      刚刚看到你的评论。我去看了你的博客,跳转正常。问题应该已经顺利解决了吧。
  2. SelfBoot
    这个方法不错,感谢