'hexo使用指南'

Hexo是一个快速,简单和功能强大的博客框架,链接hexo

极速

  • Node.js为您带来难以置信的生成速度。数百个文件只需要几秒钟的时间来构建。

Markdown 支持

  • 支持GitHub Flavored Markdown的所有功能。您甚至可以在Hexo中使用大多数Octopress插件。

单命令部署

  • 您只需要一个命令将您的网站部署到GitHub页面,Heroku或其他网站。

各种插件

  • Hexo有一个强大的插件系统。您可以为Jade,CoffeeScript插件安装更多的插件。

基本命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ npm install hexo-cli -g //全局安装hexo
$ hexo init blog //初始化博客
$ cd blog //切入blog目录
$ npm install //安装依赖
$ hexo new "My New Hello World!" //新建文章,其中'My New Hello World!'为标题
$ hexo generate //生成静态文件
$ hexo deploy //发布到服务器
$ hexo server //本地启动服务

目录结构

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
—— blog //根目录
|—— _config.yml //配置文件
├─public //生成静态文件
│ ├─2017
│ │ └─06
│ │ └─14
│ │ └─hello-world
│ ├─archives
│ │ └─2017
│ │ └─06
│ ├─css
│ │ ├─fonts
│ │ └─images
│ ├─fancybox
│ │ └─helpers
│ └─js
├─scaffolds //文章模板
├─source //源文件
│ └─_posts //新建文章
└─themes //模板
└─landscape //默认模板
├─languages
├─layout
│ ├─_partial
│ │ └─post
│ └─_widget
├─scripts
└─source
├─css
│ ├─fonts
│ ├─images
│ ├─_partial
│ └─_util
├─fancybox
│ └─helpers
└─js

配置文件_config.yml(默认模板)

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
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: 道心博客 #博客标题
subtitle: 观世间百态,聆俗世妙音 #博客副标题
description: 天人合会,豁然贯通 #博客描述
author: 道心 #作者
language: zh-CN #语言
timezone: Asia/Shanghai #网站时区
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://jsgu.net #站点url
root: /
permalink: :year/:month/:day/:title/ #访问路径格式
permalink_defaults: #
# Directory
source_dir: source #源文件
public_dir: public #静态文件
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:
# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: true #默认false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:
# Category & Tag
default_category: uncategorized
category_map:
编程: programming
生活: life
其他: other
tag_map:
# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
## theme: dao
theme: landscape
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/liuhangbiao/liuhangbiao.github.io.git //配置github 地址
branch: master

配置文件_config.yml (博客模板:blog/themes/landscape/_config.yml)

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
# Header # 头部及导航配置
menu:
Home: /
css: /categories/css/
# html: /categories/html/
Javascript: /categories/javascript/
# 趣味代码: /categories/趣味代码/
web自动化: /categories/web自动化/
教程指导: /categories/教程指导/
# 操作系统: /categories/操作系统/
# 数据库: /categories/数据库/
# Archives: /archives
rss: /atom.xml
# Content
excerpt_link: Read More
fancybox: true
# Sidebar #侧栏配置
sidebar: right
widgets:
#- znss
- recent_posts
- tagcloud
- category
# - tag
- archive
- links
# display widgets at the bottom of index pages (pagination == 2)
index_widgets:
# - category
# - tagcloud
# - archive
# widget behavior
archive_type: 'monthly'
show_count: false
# Miscellaneous
google_analytics:
favicon: /favicon.png
twitter:
google_plus:
fb_admins:
fb_app_id:

自定义文章模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# scaffolds目录下新建cat.md
文本:
---
title: {{ title }}
date: {{ date }}
tags:
category:
description:
---
# 新建文章
$ hexo new cat 'Hello World!'
配置站点域名 (根目录[blog\public]新建 CNAME文件)
1
2
3
jsgu.net
# 注意:域名需要解析到(****.github.io)

更多请参考 Hexo文档