配置Github主页

连接Github与本地

右键打开git bash

1
2
git config --global user.name "godweiyang"
git config --global user.email "792321264@qq.com"

将上面的用户名和邮箱替换为自己的。
然后生成密钥SSH key:

1
ssh-keygen -t rsa -C "792321264@qq.com"

打开github,在头像下面点击settings,再点击SSH and GPG keys,新建一个SSH,名字随便。
git bash中输入

1
cat ~/.ssh/id_rsa.pub

将输出的内容复制到框中,点击确定保存。
输入ssh -T git@github.com,如果如下图所示,出现你的用户名,那就成功了。

1
2
$ ssh -T git@github.com
Hi Mrljq! You've successfully authenticated, but GitHub does not provide shell access.

下载所需的包

1. Node:从如下官网下载所需的node版本。node下载官网

  • 下载完成后全部选择next安装即可。下载完成后在git bash里输入下列命令查看是否安装完成。
1
2
node -v
npm -v

2.安装Hexo

  • 在命令行输入以下命令
1
npm install -g hexo-cli
  • 可以输入以下命令查看是否安装到位
1
hexo -v
  • 安装Hexo完成后,在指定文件夹下打开”Git Bash”,再执行下列命令,Hexo将会在指定文件夹中新建所须要的文件:
1
2
3
hexo init myBlog
cd myBlog
npm insta11
  • 之后即可输入命令 在浏览器中输入localhost:4000即可看见效果。
1
hexo s

3. 下载主题

将博客放到Github上

  • 进入根目录下的config文件(不是这个主题的),按照下面的方式修改。

  • 第二要安装一个部署插件hexo-deployer-git,打开”Git Bach”,输如以下指令:
1
npm install hexo-deployer-git --save
  • 最后执行如下两条命令就能够部署上传啦,如下g是generate缩写,d是deploy缩写。
1
2
hexo g #先生成
hexo d #部署到Github上
  • 这时用浏览器输入用户名.github.io就可以访问刚才的网站啦。
  • 这里要把io的setting中关于page的branch设置为master。

写文章并上传

  • 博客搭好了,就开始写文章了,这里简单介绍一下,详细的文档能够看 hexo 官网。新建文章,输入如下命令便可
1
hexo new '文章标题'
  • 执行完成后能够在 /source/_posts 下看到一个文章标题.md的文章文件啦。.md 就是 Markdown 格式的文件,具体用法能够在网上找一下,语法仍是比较简单的。

  • 之后依次输入以下命令:

1
2
3
hexo g #生成文件
hexo s #本地服务器查看网站
hexo d #部署到Github 上

创建’Tag’, ‘Category’ 页面

There is no ‘tag’ or ‘category’ page in

  1. execute commands
1
2
hexo new page tag
hexo new page category
  1. enter the dictionary
    1
    cd source/tag
  2. add ‘layout’ key
1
2
3
4
5
// source\tag\index.md
——-
title: Tag
layout: tag
---

配置一些特效

  • 雪花特效: themes\hexo-theme-Chic\layout\index.ejs 中添加如下代码:
1
2
3
4
5
6
<!-- 雪花特效 -->
<script type="text/javascript"
src="https://libs.baidu.com/jquery/1.8.3/jquery.js"></script>
<script type="text/javascript"
src="https://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="/js/snow.js"></script>
  • 蜘蛛网特效: themes\hexo-theme-Chic\layout\layout.ejs 中添加如下代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script>
!
function() {
function n(n, e, t) {
return n.getAttribute(e) || t
}
function e(n) {
return document.getElementsByTagName(n)
}
function t() {
var t = e("script"),
o = t.length,
i = t[o - 1];
return {
l: o,
z: n(i, "zIndex", -1), //置于主页面背后
o: n(i, "opacity", .5), //线条透明度
c: n(i, "color", "0,0,0"), //线条颜色
n: n(i, "count", 100) //线条数量
}
}
function o() {
a = m.width = window.innerWidth ||
document.documentElement.clientWidth || document.body.clientWidth,
c = m.height = window.innerHeight ||
document.documentElement.clientHeight || document.body.clientHeight
}
function i() {
r.clearRect(0, 0, a, c);
var n, e, t, o, m, l;
s.forEach(function(i, x) {
for (i.x += i.xa, i.y += i.ya, i.xa *= i.x > a || i.x < 0 ? -1 :
1, i.ya *= i.y > c || i.y < 0 ? -1 : 1, r.fillRect(i.x - .5, i.y - .5, 1,
1), e = x + 1; e < u.length; e++) n = u[e],
null !== n.x && null !== n.y && (o = i.x - n.x, m = i.y - n.y, l
= o * o + m * m, l < n.max && (n === y && l >= n.max / 2 && (i.x -= .03 * o,
i.y -= .03 * m), t = (n.max - l) / n.max, r.beginPath(), r.lineWidth = t /
2, r.strokeStyle = "rgba(" + d.c + "," + (t + .2) + ")", r.moveTo(i.x, i.y),
r.lineTo(n.x, n.y), r.stroke()))
}),
x(i)
}
var a, c, u, m = document.createElement("canvas"),
d = t(),
l = "c_n" + d.l,
r = m.getContext("2d"),
x = window.requestAnimationFrame || window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(n) {
window.setTimeout(n, 1e3 / 45)
},
w = Math.random,
y = {
x: null,
y: null,
max: 2e4
};
m.id = l,
m.style.cssText = "position:fixed;top:0;left:0;z-index:" + d.z +
";opacity:" + d.o,
e("body")[0].appendChild(m),
o(),
window.onresize = o,
window.onmousemove = function(n) {
n = n || window.event,
y.x = n.clientX,
y.y = n.clientY
},
window.onmouseout = function() {
y.x = null,
y.y = null
};
for (var s = [], f = 0; d.n > f; f++) {
var h = w() * a,
g = w() * c,
v = 2 * w() - 1,
p = 2 * w() - 1;
s.push({
x: h,
y: g,
xa: v,
ya: p,
max: 6e3
})
}
u = s.concat([y]),
setTimeout(function() {
i()
},
100)
} ();
</script>