参考Hexo文档
一、安装Git
gitforwindows 下载安装
安装完查看git版本:
1
git --version
二、安装Node.js
node.js 选择LTS的window版本,下载安装
安装完查看node.js版本
1
2node -v
npm -v更改npm镜像源:
1
npm config set registry https://registry.npm.taobao.org/
查看npm镜像源:
1
npm get registry https://registry.npm.taobao.org/
三、安装Hexo
安装Hexo
1
npm install -g hexo-cli
四、建站
初始化博客目录
安装 Hexo 完成后,请执行下列命令,Hexo 将会在指定文件夹中新建所需要的文件。
1
2
3hexo init <folder>
cd <folder>
npm install常用命令:
- 清理缓存:
hexo clean
- 生成静态文件:
hexo g/generate
- 生成静态文件:
hexo s/server
- 组合版:
hexo clean && hexo g && hexo s
- 发布到github:
hexo d
本地访问地址:http://localhost:4000
- 清理缓存:
修改网站基本配置信息参考配置
五、将hexo部署到GitHub
生成SSH添加到GitHub
生成key,可以git部署网站
1
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
然后需要配置
1
2git config --global user.email “you@example.com”
git config --global user.name “Your Name”将这个文件拷贝到git的https://github.com/settings/keys
查看是否配置成功1
ssh -T git@github.com
GitHub创建个人仓库
新建一个 repository。如果你希望你的站点能通过域名<你的 GitHub 用户名>.github.io
访问,你的 repository 应该直接命名为<你的 GitHub 用户名>.github.io
。安装 hexo-deployer-git.:
1
npm install hexo-deployer-git --save
在 _config.yml(如果有已存在的请删除)添加如下配置:
1
2
3deploy:
type: git
repo: https://github.com/<username>/<project>运行 hexo
1
clean && hexo deploy
查看
username.github.io
上的网页是否部署成功。
六、发布文章
创建文章
1
hexo new post "title"
然后用编辑器修改好文本,发布
1
2hexo clean && hexo g && hexo s
hexo clean && hexo deploy