hexo同步博客

hexo搭建过程网上很多,这里就不叙述。主要说说在不同电脑之间同步hexo博客。

远程仓库的创建

可以使用github、OSC、coding等等,最好选择私有库,由于github只能私有库不是免费的,想节省点的可以选择免费的私有库(比如OSC、coding)。

将git SSH公钥添加至远程仓库。

.gitignore操作

在hexo根目录下新建或打开.gitignore

1
2
3
4
/.deploy_git
/public
/_config.yml
/node_modules

/.deploy_git 以及 /public 文件在进行hexo d时会重新生成
/node_modules 使用npm installcnpm install(淘宝镜像)会重新生成
/_config.yml自行保存,如不在意可以上传到远程仓库中

上传hexo文件到远程仓库

在hexo根目录下打开Git Bash

1
2
3
4
5
6
7
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git init
git add .
git commit -m "first commit"
git remote add origin ssh地址
git push -u origin master

其他电脑端操作

安装hexo过程不在叙述,进行到hexo init这步无需再执行

在Git Bash界面下把项目同步下来

1
git clone ssh地址

如_config.yml文件自行保存复制进项目根目录
继续如下操作

1
npm install 或 cnpm install(淘宝镜像)

运行hexo,以后要在本地运行博客只要输入该命令即可

1
hexo s -g

打开浏览器,输入localhost:4000,就可以在本地看到你的个人博客了

安装hexo git插件

1
2
npm install hexo-deployer-git --save 
或 cnpm install hexo-deployer-git --save(淘宝镜像)

发布更新博客

1
hexo d -g

发布成功后,访问博客page地址查看看下成果即可!

原文:大专栏  hexo同步博客


猜你喜欢

转载自www.cnblogs.com/chinatrump/p/11614975.html