hexo+next+GitHub搭建静态博客(一)-本地服务搭建

之前都是在公共的博客平台写东西,突然想自己搭建blog了。我也有自己的阿里云服务器,但一是搭载麻烦,二是数据保存是个问题。最后瞄上了Github Pages,网上也查了些资料,决定使用hexo+next来搭建自己的blog。

安装Git和NodeJS环境

因为hexo需要依赖Git和NodeJs,所以需要先安装环境。

1
2
3
Git下载地址:https://git-scm.com/download/win
NodeJS下载地址:https://nodejs.org/download/

至于安装过程我就不多写了。

安装hexo

1
2
3
4
5
6
7
#安装hexo服务
$ npm install -g hexo-cli
#初始化hexo
$ hexo init <your-hexo-site>
$ cd <your-hexo-site>
$ npm install

使用Next主题

下面来使用Next主题让站点更酷炫,当然hexo有很多主题,操作方法都类似。

安装

1
2
3
$ cd <your-hexo-site>
$ git clone https://github.com/iissnan/hexo-theme-next themes/next

配置

修改/_config.yml中的blog的主题:

1
2
3
4
5
6

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

修改/themes/next/_config.yml中的scheme,我使用的是Muse。

1
2
3
4
5
6
7
8
9
# ---------------------------------------------------------------
# Scheme Settings
# ---------------------------------------------------------------

# Schemes
scheme: Muse
#scheme: Mist
#scheme: Pisces

写文章

1
2
3
4
$ hexo new "Hello World"

$ hexo s --debug

访问http://localhost:4000,确保站点正确运行。