本站搭建小结

本小站采用 hexo 结合[githubpage]搭建,hexo资料:

安装hexo

前置条件

安装hexo

1
$ npm install hexo --no-optional

常用hexo 命令

1
2
3
4
5
$ hexo init [path] # 初始化一个项目
$ hexo new "My New Post" # 新建一篇博文
$ hexo server # 本地调试
$ hexo generate # 生成HTML
$ hexo deploy # 部署到远程服务器

======
. 代表初始化项目的根目录
项目的全局配置文件 ./_config.yml
主题的配置文件 ./theme/(themename)/_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
80
81
82
83
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/
# Site
title: Puzzlefun
subtitle: stay hungry stay foolish
description: 学习iOS笔记,分享自己的学习路程,记录脚下的每一个脚印
author: invokefear
language: zh-CN
timezone:
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: puzzlefun.github.io
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: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:
# Category & Tag
default_category: uncategorized
category_map:
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: freemind
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/puzzlefun/puzzlefun.github.io.git
feed:
type: atom
path: atom.xml
limit: 20
hub:
## https://github.com/PaicHyperionDev/hexo-generator-search
search:
path: search.xml
field: post

配置主题

下载主题
e.g freemind

1
2
3
cd theme/
$ git clone https://github.com/wzpan/hexo-theme-freemind.git themes/freemind
$ npm install hexo-tag-bootstrap --save

在全局配置文件_config.yml 中Extension节中设置

1
theme: freemind

hexo theme提供了多种主题

主题配置

本站采用的主题为 freemind

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
slogan: "好好学习 天天向上"
theme: false
inverse: false
menu:
- title: Archives
url: archives
intro: "All the articles."
icon: "fa fa-archive"
- title: Categories
url: categories
intro: "All the categories."
icon: "fa fa-folder"
- title: Tags
url: tags
intro: "All the tags."
icon: "fa fa-tags"
- title: About
url: about
intro: "About me."
icon: "fa fa-user"
links:
- title: "Puzzle4fun"
url: https://github.com/puzzlefun
intro: "My Github account."
icon: "fa fa-github"
- title: "My LinkedIn"
url: https://cn.linkedin.com/in/carl-liu-337796a2
intro: "My Linkin account."
icon: "fa fa-linkedin"
widgets:
- search
- category
- tagcloud
- recent_posts
- links
rss: atom.xml
fancybox: true
favicon: favicon.png
duoshuo_shortname: puzzlefun
# Analytics
google_analytics:
enable: false
siteid:
baidu_tongji:
enable: true
siteid: e358945bd22b2347e568dd59e2f62845
# search
# swiftype_key: ZP2ZSuHgipSZfRyU8uTR
# share widgets
bdshare: true
jiathis: false

添加 网站统计

e.g 百度统计创建一个网站统计id

1
2
3
baidu_tongji:
enable: true
siteid: [your baidu tongji id]

该配置会在主题的layout中增加统计的代码,根据自己的需要可以适当的

添加 多说评论

引用