安装 hexo 和 next
hexo是通过npm安装的,npm是nodejs下的包管理器,类似Python里的pip
- nodejs下载地址: http://nodejs.cn/download/
- nodejs在win 10下的安装和正常的软件安装无异,安装过程中有一步骤是选择安装依赖,确认后会在powershell中执行
安装完成后,打开cmd验证
1
node -v
v12.16.1
1
npm -v
6.13.4
安装npm
- 官方给出的安装指令是
npm install hexo-cli -g
- 安装完成后创建一个文件夹blog,然后执行
hexo init
完成初始化 - 执行
hexo s
启动本地预览服务,默认网址为 http://localhost:4000/ ,可以使用 -p 指定端口
- 官方给出的安装指令是
- 安装Next主题
- 在 hexo init 过的文件夹blog中
git clone https://github.com/iissnan/hexo-theme-next themes/next
- 修改站点根目录下的 _config.yml 文件中 theme: next
- 在 hexo init 过的文件夹blog中
申请 github.io 的公共仓库
- 到个人github目录下repositories,点击new
- Repository name 填和 ${owner}.github.io ,点击 create repository 就会生成个人主页仓库地址
- 点击进入 项目repo ,点击 clone or download ,选择 http 或 ssh 方式保存repo链接
将本地的hexo项目发布到github
- 需要安装hexo发布到git的插件
npm install hexo-deployer-git --save
- 修改站点根目录下的 _config.yml 中的内容
1
2
3
4deploy:
type: git
repository: ${repo链接}
branch: master - 执行部署指令
hexo clean && hexo g && hexo d
- 等待执行完毕,即可以访问 ${owner}.github.io 来查看自己的博客主页