记录我github的hexo的搭建Blog之路

398 阅读2分钟

搭建完成demo

第一步:在Github上搭建博客

1.在Github上创建一个新的repository,repository的名字写成xxxxx.github.io的形式,以保证你创建的是一个博客
2.然后在创建成功的repository中的setting中的GitHub Pages选项中点击choose theme,选择一个主题
3.回到GitHub Pages中可以查看到你得博客地址https://xxxxx.github.io/,进入链接即是你的Git博客地址。

第二步:hexo相关操作

Git自带的博客主题还是有点丑的,我选择的是使用hexo的yilia主题,接下来就是讲如何使用hexo进行主题博客搭建
1.安装hexo

1.1 搭建环境 包括node.js和git环境,gitHub账户的配置(这个可以在官网自行下载,并且下载好git)
1.2 使用git bash 进行安装hexo 

安装Hexo依赖

npm install hexo-cli -g

然后install组件

npm install hexo --save

查看版本:成功之后会是如下信息

hexo -v

hexo-cli: 1.1.0
os: Windows_NT 6.1.7601 win32 x64
http_parser: 2.7.0
node: 6.11.2
v8: 5.1.281.103
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2l

2.配置hexo

hexo init xxxxx.github.io(这个是你之前的github 博客名)

接下来连接你得远程git

git remote add origin https://github.com/sss(github用户名)/xxx(GitHub博客名).github.io.git

3.配置Git

在编辑器中修改配置文件_config.yml

## Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/sss(github用户名)/xxx(GitHub博客名).github.io.git
  branch: master

然后执行

npm install hexo-deployer-git --save

4.clone yilia主题

使用git bash在xxxxx.github.io目录下执行

git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

然后在编辑器中配置文件_config.yml中修改主题

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

并且找到themes文件夹,可以把之前的博客主题删除掉

设置完主题,部署到git上:

hexo d -g

4.启动hexo

hexo s

注意部署问题,可以先在自己主机生成ssh key,然后添加到你自己的github的ssh key; 查看是否部署成功,可以用以下命令:

ssh -T git@github.com

成功的样子是下面这样:

Hi appledusiyong! You've successfully authenticated, but GitHub does not provide shell access.

第三步 进行相关页面设置

1.设置头像;

如果头像图片是本地,存放的路径是:themes/yilia/source/img下

在themes/yilia/_config.yml配置文件中添加设置:

 #你的头像url
 avatar: /img/girl2_1.jpg
2.