搭建免费博客(上)

搭建过程

github 帐号注册及仓库建立

帐号注册

github官网: github

创建仓库

仓库名是username.github.io 注意:username和github用户名一定要一致,这是用的是github 的博客空间

1
shanguanyunya/shanguanyunya.github.io

软件安装

linux 操作系统安装和yum 源配置(可以访问外网)

git 安装

1
yum install git -y

node.js 安装

1
2
wget https://raw.github.com/creationix/nvm/master/install.sh
sh install.sh

重新登录一个新会话

1
nvm install 4

hexo 安装

1
npm install hexo-cli -g

配置

博客文件夹创建

1
2
3
mkdir /data/hexo/
cd /data/hexo/
hexo init shanguanyunya.github.io

主题安装

1
2
cd /data/hexo/shanguanyunya.github.io
git clone https://github.com/iissnan/hexo-theme-next themes/next

更多主题: themes

配置文件设置

1
cp _config.yml _config.yml.bak.20171017-1
1
2
3
4
5
6
7
8
9
title: shanguanyunya's blog
author: yunya
language: zh-Hans
theme: next
deploy:
type: git
repo: git@github.com:shanguanyunya/shanguanyunya.github.io.git

说明:key value 冒号后面有空格,git repo 地址也可以用https的形式https://github.com/shanguanyunya/shanguanyunya.github.io.git

安装成功测试及发布

本地测试验证

1
hexo s -p 8080

浏览器访问 https://localhost:8080

发布

发布工具安装

1
npm install hexo-deployer-git --save

发布到github

1
hexo clean && hexo g && hexo d

进阶配置

阅读统计

注册LeanCloud帐号 https://leancloud.cn/
参考: notes.wanghao.work

修改配置文件

1
2
3
4
5
6
7
cd /data/hexo/shanguanyunya.github.io/themes/next
# Show number of visitors to each article.
# You can visit https://leancloud.cn get AppID and AppKey.
leancloud_visitors:
enable: true
app_id: xxxxxxxxxxxxxxxxxx
app_key: xxxxxxxxxxxxxxxxx

404公益页面

修改配置文件,打开404导航页

1
2
3
4
5
6
7
8
9
menu:
home: / || home
about: /about/ || user
#tags: /tags/ || tags
#categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
#sitemap: /sitemap.xml || sitemap
commonweal: /404/ || heartbeat

创建404页面

1
2
3
4
5
6
7
8
9
10
cd /data/hexo/shanguanyunya.github.io
hexo new page "404"
cd source/404/
[root@test 404]# cat index.md
---
title: 404
date: 2017-10-17 16:13:56
---
<script type="text/javascript" src="//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js" charset="utf-8" homePageUrl="https://shanguanyunya.github.io/" homePageName="回到我的主页"></script>

----纸上得来终觉浅绝知此事要躬行----
最好的赞赏是您的阅读!
0%