Hello World

吞风吻雨葬落日 欺山赶海踏雪径

0%

hexo博客搭建记录

hexo博客搭建记录

常用网址记录

搭建步骤

首先需要安装nodejs。验证脚本如下:

1
2
3
4
➜  forgblog git:(master) ✗ node -v
v8.9.4
➜ forgblog git:(master) ✗ npm -v
5.6.0

安装hexo

1
npm install hexo -g

检查hexo是否安装成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
➜  forgblog git:(master) ✗ hexo -v
hexo: 3.5.0
hexo-cli: 1.0.4
os: Darwin 16.4.0 darwin x64
http_parser: 2.7.0
node: 8.9.4
v8: 6.1.534.50
uv: 1.15.0
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 57
nghttp2: 1.25.0
openssl: 1.0.2n
icu: 59.1
unicode: 9.0
cldr: 31.0.1
tz: 2017b

初始化hexo文件夹

1
hexo init

在博客目录中安装所需要的组件

1
npm install

安装完成后创建新的文章

1
$ hexo new "My New Post"

More info: Writing
生成博客文件

1
hexo g

More info: Generating

启动服务

1
hexo s

More info: Server

发布到git 先安装依赖

1
npm install hexo-deployer-git --save

配置deploy

1
2
3
4
deploy:
type: git
repo: git@github.com:xxx/xxx.git
branch: master

然后执行

1
$ hexo deploy

More info: Deployment

主题配置

landscape-plus

代码相关样式文件

1
/themes/landscape-plus/source/css/_partial/highlight.styl

主题的相关变量文件

1
themes/landscape-plus/source/css/_variables.styl

next

安装主题

1
git clone https://github.com/theme-next/hexo-theme-next themes/next

是否启用动画

1
2
themes/next/_config.yml
motion 设置为 true/false

样式修改
./themes/next/source/css/_common/components/post/post-meta.styl 中 修改标题下留白。

1
2
.posts-expand .post-meta {
margin: 3px 0 60px 0;

改成

1
2
.posts-expand .post-meta {
margin: 3px 0 30px 0;

./themes/next/source/css/_common/components/post/post-button.styl 中 修改按钮留白。

1
2
3
.post-button {
margin-top: 40px;
}

改成

1
2
3
.post-button {
margin-top: 5px;
}

./themes/next/source/css/_schemes/Gemini/index.styl 中文章块下的留白。

1
2
3
4
5
6
.post-block {
padding: $content-desktop-padding;
background: white;
box-shadow: $box-shadow-inner;
border-radius: $border-radius-inner;
}

改成

1
2
3
4
5
6
.post-block {
padding: $content-desktop-padding $content-desktop-padding 20px $content-desktop-padding;
background: white;
box-shadow: $box-shadow-inner;
border-radius: $border-radius-inner;
}

问题

Chinese TOC cannot jump

中文的目录无法跳转的问题,修改文件source/js/utils.js。修改内容见详情
https://github.com/theme-next/hexo-theme-next/pull/1540/files

Accessing non-existent property

1
2
3
4
5
6
7
8
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
(node:16104) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16104) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:16104) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:16104) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:16104) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:16104) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

参考 https://github.com/stylus/stylus/pull/2538/commits/16e2a6c6f96f80b0d700411879f1c13991a0a1a5

修改
.\node_modules\hexo-renderer-stylus\node_modules\stylus\lib\nodes\index.js
.\node_modules\hexo-renderer-stylus\node_modules\nib\node_modules\stylus\lib\nodes\index.js

新增

1
2
3
exports.lineno = null;
exports.column = null;
exports.filename = null;