Build my blog

1. 目标是搭建一个如下图的博客

image.png

2. 工具 + 环境

1
2
3
4
1.Mac 
2.Hexo
3.Github
4.Theme

3.第一步 Hexo

3.1 查看自己的电脑上是否有安装 GitNode.js,没有就按照下面步骤操作:

1
2
3
4
5
6
7
$ brew install git //安装 git
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh //安装 nvm
$ nvm install stable //安装 Node.js
$ npm install -g hexo-cli //安装 Hexo
$ hexo init <folder> //找一个地方新建文件夹用来放置博客网站的配置文件等,folder是文件夹路径
$ cd <folder>
$ npm install

4. 第二步 Github

  1. 新建 repository, 填写 repository name : username.github.io (注:username 替换成你自己的)
  2. 复制 repository 的 url

5. 第三步 Theme

1
2
3
4
$ cd <folder>
$ cd themes
$ git clone https://github.com/viosey/hexo-theme-material.git material
$ cd material

6.第四步 配置文件

  1. 打开前面新建的文件夹目录下的 _config.yml

2.修改配置

1
2
3
4
5
6
theme: material //默认是landscape, 改成 material
//最下面两行删掉,改成下面四行
deploy:
type: git
repository: https://github.com/chenxiaoyanemile/chenxiaoyanemile.github.io.git(注:改成你自己的)
branch: master

7.第五步 查看结果

1
2
$ cd /Users/emily/Documents/MyBlog
$ hexo clean && hexo g && hexo d

运行成功后在浏览器输入:http://chenxiaoyanemile.github.io/,现实如下:

image.png

有乱码出现?打开前面新建的文件夹目录下的 _config.yml, 改一下配置

1
2
3
4
5
6
7
title: 喜欢书的女孩
subtitle: 程序媛
description: 我自风情万种,与世无争
keywords:
author: Emily Chen
language: zh-CN
timezone:

八、修改头像

找到 themes/material/source/img/avatar.png, 删除,然后找一张你想要作为你自己的头像的图片重命名为avatar.png,然后在重新部署即可。

九、增加新的 blog

1
2
3
/Users/sweetgirl/Documents/Myblog 
hexo clean && hexo g && hexo d
hexo server