How to use hexo?

Hexo基本指令

init

1
$ hexo init [folder]

新建一个网站,如果没有设置`folder`,Hexo默认在目前的文件夹建立网站。

new

1
$ hexo new [layout] <title>

新建一片文章。如果没有设置layout的话,默认使用_config.yml中的default_layout参数代替。如果标题包含空格的话,请使用引号括起来。

generate

1
2
$ hexo generate
$ hexo g # 简写

server

1
$ hexo server

启动服务器。默认情况下,访问网址为:http://localhost:4000/

选项 描述
-p,--port 重设端口
-s, --static 只使用静态文本
-l,--log 启动日记记录,使用覆盖记录格式

deploy

1
2
$ hexo deploy
$ hexo d # 简写

render

1
$ hexo render <file1> [file2] ...

渲染文件。

clean

1
$ hexo clean

清楚缓存文件(db.json)好已经生成的静态文件(public)。

在某些情况(尤其是更换主题后),如果发现您对站点的更改没有生效,可以使用此命令。

list

1
$ hexo list <type>

列出网站资料。

version

1
$ hexo version

显示Hexo版本。

显示草稿

1
$ hexo --draft

显示source/_drafts文件夹中的草稿文件。

浏览草稿文章

1
$ hexo S --draft

publish

1
2
$ hexo publish [layout] <filename>
$ hexo P [layout] <filename> # 缩写

发表草稿。

其中 为不包含 md 后缀的文章名称。它的原理只是将文章从 source/_drafts 移动到 source/_posts 而已。

之后的 hexo generate 与 hexo deploy 的用法就完全一样了。

若日后想将正式文章转为为草稿,只需手动将文章从 source/_posts 目录移动到 source/_drafts 目录即可。

自定义CWD

1
$ hexo --cwd /path/to/cwd

自定义当前工作目录(Current working dirctory)的路径。

在主页截断

  • 方法1: 在文中插入以下代码

    1
    <!--more-->

  • 方法2: 在文章中的front-matter中添加description,

    1
    2
    3
    4
    5
    6
    7
    ---
    title:
    date: 2018-08-14 15:21:22
    categories:
    tags:
    description: 描述。。
    ---

分类和标签

只有文章支持分类和标签,您可以在 Front-matter 中设置。在其他系统中,分类和标签听起来很接近,但是在 Hexo 中两者有着明显的差别:分类具有顺序性和层次性,也就是说 Foo, Bar 不等于 Bar, Foo;而标签没有顺序和层次。

1
2
3
4
5
categories:
- Diary
tags:
- PS3
- Games

定义一段代码。

1
2
3
4
5
import os
import numpy as np

for i in range(10):
print('now is ', i)

显示一幅图像。

1
{% asset_img 003.jpg This is an example image %}

Hexo 资源

hexo官网

theme-next使用说明

使用hexo,如果换了电脑怎么更新博客?

其他参考博客: 我的个人博客之旅:从jekyll到hexo HEXO+NEXT主题个性化配置

hexo的next主题个性化配置教程

基于Hexo+Node.js+github+coding搭建个人博客——进阶篇(从入门到入土)

数学公式渲染 让 Hexo Next (v8.0.0) 支持 LaTeX 数学公式

Rendering Math Equations in Hexo