hexo博客创建以及备份

首先确保本地环境已经安装node

创建

  1. 环境安装
1
2
3
npm -g install hexo-cli 
npm -g install hexo-deployer-git
npm install
  1. 初始化博客
1
hexo init myblog
  1. 修改配置文件
1
2
cd myblog
vim _config.yml # 详细参考官方文档
  1. 下载主题并解压的博客根目录下的themes目录(以next主题为例)
1
2
3
4
5
cd themes/
git clone https://github.com/theme-next/hexo-theme-next.git
mv hexo-theme-next-master next
cd next
vim _config.yml # 详细参考官方文档

备份

确保目前目录在博客的根目录

  1. 初始化git仓库
1
git init

git会自动创建合适的.gitignore文件,所以不必担心啦,如果你想额外的添加也是可以的哦。

1
2
3
4
5
6
7
.DS_Store
Thumbs.db
b.json
*.log
node_modules/
public/
deploy*/
  1. 设置远程仓库
1
git remote add origin https://github.com/username/repository_name  
  1. 查看本地文件的状态
1
git status
  1. 推送本地分支
1
2
3
git add *
git commit -m "backup"
git push origin local_branch:remote_branch