Hexo+Nest搭建个人博客

1.安装Node.js

Node.js是能够在服务器端运行JavaScript 的开放源代码、跨平台 JavaScript 运行环境。

查看node版本 node -v

查看npm包管理器版本 npm -v

2. npm安装Hexo

1
$ npm install -g hexo-cli

3. 使用Hexo搭建博客

1
2
3
$ mkdir blog
$ cd blog/
$ npm install

4.启动博客

1
2
3
4
5
6
7
8
$ hexo s // 启动本地服务 localhost:4000 hexo默认创建了主题为hello world的文章
$ hexo n "我的第一篇博客文章"
$ cd source/_posts/
$ subl 我的第一篇博客文章.md // 用sublime进行编辑
$ cd ../.. // 切换到myblog目录
$ hexo clean // 清理
$ hexo g // 生成
$ hexo s // 启动

5. 部署到xxx.gitHub.io

github 新建仓库

Create new repository

仓库名与GitHub帐号名相同

repository name : username.github.io // 浏览器输入该地址可访问

在blog目录下安装git部署的插件

安装
hexo-deployer-git

1
$ npm install hexo-deployer-git --save

修改站点配置文件 /blog/_config.yml

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/username/username.github.io.git
  branch: master

部署到远端

1
2
3
$ git config --global user.email "you@example.com"
$ git config --global git config --global user.name "Your Name"
$ hexo d

更改站点配置文件 /blog/_config.yml
theme: next

重新生成部署

hexo clean
hexo g
hexo s
hexo d

添加评论系统
https://bluelzy.com/articles/use_valine_for_your_blog.html

参考

https://www.bilibili.com/video/BV1Yb411a7ty?from=search&seid=15921694224540162753