Hexo折腾过程#
01#安装git#
下载地址:https://git-scm.com/downloads
02#安装Node.js#
下载地址:https://nodejs.org/en/download/
03#安装Hexo#
进入Git Bash,在某个地方创建一个目录,比如E:/hexo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
cd /e/hexo
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install hexo-cli -g
hexo init
cnpm install
cnpm install hexo-server --save
cnpm install hexo-deployer-git --save
cnpm install hexo-generator-index --save
cnpm install hexo-generator-archive --save
cnpm install hexo-generator-tag --save
cnpm install hexo-generator-feed --save
cnpm install hexo-generator-sitemap --save
cnpm install hexo-generator-baidu-sitemap --save
cnpm install hexo-related-popular-posts --save
#cnpm install hexo-generator-searchdb --save
#cnpm install hexo-algolia --save
#cnpm install hexo-asset-image --save
#cnpm instal hexo-util --save-dev
#cnpm install hexo-leancloud-counter-security --save
|
04#安装Next主题#
1
2
|
git clone https://github.com/theme-next/hexo-theme-next.git themes/next
git clone https://github.com/theme-next/theme-next-algolia-instant-search themes/next/source/lib/algolia-instant-search
|
05#配置Hexo#
配置文件:_config.yml
官方文档:https://hexo.io/zh-cn/docs/
个人喜好配置:
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
|
# 设置网站信息
title: 凌点时代
subtitle:
description: 一个码农。
keywords:
author: Zeyes
language: zh-CN
timezone: Asia/Shanghai
url: http://www.zeyes.org
root: /
permalink: blog/:year/:month/:urlname.html
new_post_name: :year-:month-:day-:title.md
index_generator:
path: ''
per_page: 10
order_by: -date
# 归档每页文章数量
archive_generator:
per_page: 50
yearly: true
monthly: true
tag_generator:
per_page: 10
# 设置主题
theme: next
# sitemap
sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml
# 部署
deploy:
type: git
repo: git@server:/data/repo/blog.git
branch: master
|
06#配置Next#
(1) 复制配置文件#
在hexo的source下新建_data文件夹,将theme/next目录下的_config.yml复制到source/_data文件夹,并重命名为next.yml
PS:值得注意的是,hexo也有配置文件,称为站点配置文件,而next里面的配置文件称为主题配置文件
(2) 配置next.yml#
此处根据官方文档,进行个性化配置。
Next官方文档:http://theme-next.iissnan.com/getting-started.html
另外一份文档:https://github.com/iissnan/hexo-theme-next/wiki
07#配置服务器#
配置文档1:https://segmentfault.com/a/1190000005723321
配置文档2:http://www.swiftyper.com/2016/04/17/deploy-hexo-with-git-hook/
08#部署#
09#常用操作#
1
2
3
4
5
6
7
8
|
# 新建文章
hexo new pages "xxxx"
# 清理
hexo clean
# 生成
hexo g
# 本地查看
hexo s
|
10# 插件使用#
1
2
|
export HEXO_ALGOLIA_INDEXING_KEY=xxx
hexo algolia
|
11#一些踩过的坑#
(1) 经常用着用着就不认hexo命令了#
解决办法:
删除node_modules文件夹在npm install一下就可以了
(2) 主题页面部署后没有正确显示,只显示默认主题#
解决办法:
- 删除.deploy_git文件夹
- hexo clean && hexo g
- 在服务器上删除重建blog.git
- hexo d
Ps: 这个问题至今未真正解决,莫名其妙就好了。