一、创建新的页面和文章

使用默认hexo命令即可:

1
2
3
4
5
6
7
8
# 创建新页面
hexo new page pagename
# 简化命令
hexo n page pagename
# 创建新文章
hexo new post postname
# 简化命令
hexo n post postname

由于butterfly主题的一些特性,所以更改了./scaffolds目录下的page.mdpost.md,使得其在生成页面或文章的时候,会自动生成主题可能需要的Front-matter

Front-matter 是文档最上方以 —- 分隔的区域,用于指定各种参数。

下面分别是page页和post页的Front-matter的参数和各参数的用法。

Page Front-matter

参数列表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
title:
date:
updated:
type:
comments:
description:
keywords:
top_img:
mathjax:
katex:
aside:
aplayer:
highlight_shrink:
---

参数用法

参数 用途
title 【必需】頁面標題
date 【必需】頁面創建日期
type 【必需】標籤、分類和友情鏈接三個頁面需要配置
updated 【可選】頁面更新日期
description 【可選】頁面描述
keywords 【可選】頁面關鍵字
comments 【可選】顯示頁面評論模塊(默認 true)
top_img 【可選】頁面頂部圖片,可输入url地址,也可以设置为false,不显示顶图
mathjax 【可選】顯示mathjax(當設置mathjax的per_page: false時,才需要配置,默認 false)(暂未安装)
katex 【可選】顯示katex(當設置katex的per_page: false時,才需要配置,默認 false)(暂未安装)
aside 【可選】顯示側邊欄 (默認 true)
aplayer 【可選】在需要的頁面加載aplayer的js和css(暂未配置)
highlight_shrink 【可選】配置代碼框是否展開(true/false)(默認為設置中highlight_shrink的配置)

备注

如果没有特殊需求,除了必选项,其余各项缺省即可

Post Front-matter

参数列表

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
title: 
date:
updated:
sticky:
tags:
categories:
password:
abstract:
message: .
wrong_pass_message:
wrong_hash_message:
keywords:
description:
top_img:
comments:
cover:
toc:
toc_number:
auto_open:
copyright:
copyright_author:
copyright_author_href:
copyright_url:
copyright_info:
mathjax:
katex:
aplayer:
highlight_shrink:

参数用法

参数 用途
title 【必需】文章標題
date 【必需】文章創建日期
updated 【可選】文章更新日期
sticky 【可选】文章置顶,数字越大,优先级越高
tags 【可选】文章标签
categories 【可选】文章分类
password 【可选】给博客加密,在此处输入密码即可
abstract: 【可选】未知
message 【可選】加密文章提示
wrong_pass_message 【可选】加密文章密码错误提示
wrong_hash_message 【可选】未知
keywords 【可選】文章關鍵字
description 【可選】文章描述
comments 【可選】顯示文章評論模塊(默認 true)
top_img 【可選】文章頂部圖片
cover 【可选】文章縮略圖(如果沒有設置top_img,文章頁頂部將顯示縮略圖,可設為false/圖片地址/留空)
toc 【可選】顯示文章TOC(默認為設置中toc的enable配置)
toc_number 【可選】顯示toc_number(默認為設置中toc的number配置)
auto_open 【可選】是否自動打開TOC(默認為設置中toc的auto_open配置)
copyright 【可選】顯示文章版權模塊(默認為設置中post_copyright的enable配置)
copyright_author 【可選】文章版權模塊的文章作者
copyright_author_href 【可選】文章版權模塊的文章作者鏈接
copyright_url 【可選】文章版權模塊的文章連結鏈接
copyright_info 【可選】文章版權模塊的版權聲明文字
mathjax 【可選】顯示mathjax(當設置mathjax的per_page: false時,才需要配置,默認 false)(暂未安装)
katex 【可選】顯示katex(當設置katex的per_page: false時,才需要配置,默認 false)(暂未安装)
aplayer 【可選】在需要的頁面加載aplayer的js和css(暂未配置)
highlight_shrink 【可選】配置代碼框是否展開(true/false)(默認為設置中highlight_shrink的配置)

备注

如果没有特殊需求,除了必选项,其余各项缺省即可。

二、更新站点

由于安装了hexo-doubanhexo-calendar两个插件,和默认命令有冲突,所以文章写好后,不能使用简化命令直接对站点进行更新,需要采用以下命令。

1
2
3
4
5
6
7
8
9
10
#清空缓存,删除pulic目录
hexo clean
# 生成静态文件,生成public目录
hexo generate
# 不可直接用hexo g来生成静态文件,但可以使用以下简化命令
hexo ge
# 部署网站
hexo deploy
# 不可直接用hexo d来部署,但可以使用一下简化命令
hexo de

可选命令:

1
2
3
4
5
6
7
8
9
Usage: hexo generate
Description:
Generate static files.
Options:
-b, --bail Raise an error if any unhandled exception is thrown during generation
-c, --concurrency Maximum number of files to be generated in parallel. Default is infinity
-d, --deploy Deploy after generated,生成后直接部署
-f, --force Force regenerate
-w, --watch Watch file changes,只生成发生改变的页面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 在执行hexo generate之后,可以使用该命令更新豆瓣数据,默认会生成books,game,movies页面
hexo douban
#########
#Usage: hexo douban
#Description:
#Generate pages from douban
#Options:
# -b, --books Generate douban books only
# -g, --games Generate douban games only
# -m, --movies Generate douban movies only

#########因为只有books和movies进行了标记只需要执行以下命令即可
hexo douban -bm

1
2
3
4
# 在执行hexo generate之后,可以使用该命令更新关于页面网站活动数据
hexo gc -w=40
#Usage: hexo gc
#Generate calendar.json