通过修改官方提供的hexo模板,搭建自己的个人博客。
Windows安装Node.js
检验
Node.js安装完成后,cmd窗口输入:
node -v
npm -v
出现版本标识,说明安装成功
设置淘宝源
永久设置淘宝源(由于Node的官方模块仓库网速太慢,模块仓库需要切换到阿里的源)
npm config set registry http://registry.npm.taobao.org/
Windows安装Git
Hexo安装
Node.js和Git程序安装完成后,即可使用 npm 安装 Hexo
npm install -g hexo-cli
博客初始化
先创建一个博客目录 如:E:\hexo(注意:路径中不要有中文)
hexo init haohaodatablog
npm install
清理缓存
hexo clean
生成静态文件
hexo g
启动服务器
hexo s
启动后可以查看博客
http://localhost:4000/
注册Github账号
1、注册 英文名称简约 好记 高大尚 如:https://github.com/haohaodata
2、在你的windows上cmd执行:(-C 后面跟你自己的邮箱地址) 一直回车 执行完成就ok
ssh-keygen -t rsa -b 4096 -C "xxxxx@163.com"
3、去以下路径找到公钥文件id_rsa.pub
/c/Users/Administrator/.ssh/id_rsa.pub
4、将id_rsa.pub中的内容复制到Gihub上
5、然后测试,本机和你的github是否能联通
ssh -T git@github.com 第一次执行 是需要输入yes
6、配置本地Git的信息
git config --global user.name "haohaodata"
git config --global user.email "haohao@163.com"
7、在Github上创建仓库haohaodata.github.io,切记和haohaodata的一致
https://github.com/haohaodata/haohaodata.github.io
修改模板
1、选择好一个模板,找到对应的Github地址
2、clone仓库
Administrator@G0XO2VBVTUOBVSS MINGW64 /e/blog
git clone https://github.com/hackeruncle/hackeruncle-hexo.git ./haohaodata-hexo
Administrator@G0XO2VBVTUOBVSS MINGW64 /e/blog
$ cd hackeruncle-hexo/
3、下载好之后,修改_config.yml 中的仓库地址
deploy:
type: git
repo: git@github.com:haohaodata/haohaodata.github.io.git
branch: master
4、修改好之后执行命令
hexo clean && hexo generate && hexo server
5、查看
open web: http://localhost:4000
6、本地测试没问题之后,就可以推送到Github上
hexo clean && hexo deploy
7、查看(这样其他人通过以下地址就可以访问你的博客了)
https://haohaodata.github.io