hexo 迁移至新电脑

迁移

  • 安装nodejs和git:
  • 配置git,生成ssh key,添加至github,使当前电脑的git与你的github相连:
1
2
3
git config --global user.name "username"
git config --global user.email "email@example.com"
ssh-keygen -t rsa -C "email@example.com"
  • 拷贝原电脑项目文件中的_config.yml,themes,source,scaffolds,package.json,.gitignore到新电脑新建的文件夹中;
  • 使用git bash 进入此新建文件夹:
  • 执行如下命令(为新电脑全局安装hexo,安装项目依赖,安装hexo插件hexo-depolyer-git):
1
2
3
npm install hexo-cli -g
npm install
npm install hexo-deployer-git --save
  • 接下来创建新博客,并测试是否成功:
1
2
3
hexo new "myNewTestBlog"
hexo g
hexo s
  • 若本地成功部署,使用如下命令,部署至云端:
1
hexo d

报错解决

  • 部署至云端时可能出现以下错误:
1
2
3
4
5
6
7
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No error
  • 解决:将_config.yml中,原来加过的github源地址,改为下面形式(可能是更换新电脑,项目未克隆到本地,而出现的github项目验证的问题)
1
2
3
4
deploy:
type: git
repository: ssh://git@github.com/yangerle/yangerle.github.io(注意username有大写换为小写,这样才能识别)
branch: master

更多精彩->请进入我的博客

参考

hexo博客换电脑之后配置

hexo无法上传到github 试了各种办法依然无法成功,小白求助