blog的搭建
此博客是github,用hexo,并用使用next主题进行配置和搭建。
吐槽一下,作为一名纯种的后端搭建blog,尽管网上有说明,但是还是觉得有些许吃力。特别是我换顶部图片,简直是我一步一步试出来的
搭建步骤
- 注册一个github,并且新建一个名字一样的github仓库
- 配置本地的hexo环境
- 下载next主题
- 直接在
_posts
下开始写博客 - 大功告成
注意:
问题1:背景图片更换
解决:在main.styl
加入@import "_custom/styles.styl"
,背景图片放在themes\next\source\images
文件夹中,本地创建themes\next\source\css\ _custom\style.styl
文件。
1 | body { |
问题2:顶部图片更换
解决:在headerband.styl
中插入下面那句话,背景图片放在站点的source/image下
1 | .headband { |
问题3:文章置顶
解决:直接复制替换node_modules/hexo-generator-index/lib/generator.js的内容
1 | ; |
配置插件
$ npm uninstall hexo-generator-index –save
$ npm install hexo-generator-index-pin-top –save
然后在需要置顶的文章的Front-matter中加上top: true或者top数字top: 1:
1 | title: 置顶 |
按照数字大小依次往下置顶排序
问题4:博客提交
解决:调用blog_push.sh
是提交,blog_localtest.sh
是在本地查看
问题5:blog文章中图片添加
解决:在_post
目录下创建一个同名文件夹,放图片,在文章中插入
。
环境安装
- Node.js 安装,node在debian仓库只有10版本,hexo需要12以上参考解决方案,安装时必须在梯子环境下
1
2
3
4
5sudo curl -sL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
#将nodesource_setup.sh中 DISTRO=$(lsb_release -c -s) 修改为 DISTRO=stable
sudo bash nodesource_setup.sh
sudo apt-get install -y nodejs
node -v
问题4:添加全屏背景并文章透明
- 在
hexo/source/images
下增加图片background.jpg
- 在
hexo/themes/hexo-theme-next/source/_data
下新建styles.styl
文件,文件内容为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
43body {
background:url(/images/background.jpg);
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
// background-size: 100% 100%;
background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
-moz-background-size: cover;
-ms-background-size: cover;
}
//博客内容透明化
//文章内容的透明度设置
.content-wrap {
opacity: 0.8;
}
.main-inner {
// margin-top: 60px;
// padding: 60px 60px 60px 60px;
//opacity: 0.8;
}
//菜单栏的透明度设置
.header-inner {
background: rgba(255,255,255,0.8);
}
//搜索框(local-search)的透明度设置
.popup {
opacity: 0.8;
}
.post-block {
background: rgba(255,255,255,0.7) none repeat scroll !important;
}
.sidebar-inner {
background: rgba(255,255,255,0.7) none repeat scroll !important;
}