Hexo 写作速查

新建内容

1
2
3
hexo new "我的第一篇文章"          # 新建文章 -> source/_posts/我的第一篇文章.md
hexo new page "about" # 新建页面 -> source/about/index.md
hexo new draft "草稿" # 新建草稿,发布用 hexo publish 草稿

本地预览与构建

1
2
3
npm run server    # 等价于 hexo server,浏览器打开 http://localhost:4000
npm run clean # 清理缓存和 public/
npm run build # 等价于 hexo generate,生成到 public/

改完文章后,如果预览页面没更新,先 hexo clean 再 hexo server。

Front-matter 常用字段

1
2
3
4
5
6
7
8
9
10
11
---
title: 文章标题
date: 2026-10-30 21:30:00 # 发布时间
update: 2026-10-30 21:30:00 # 更新时间(可选)
tags: [Hexo, 教程] # 标签
categories: [教程] # 分类(可多层,如 [主站建设, 教程])
description: 文章摘要 # 列表卡片和 SEO 描述
cover: /img/cover.png # 封面图(可选)
top: true # 置顶(可选)
comments: true # 是否开启评论(配置评论系统后生效)
---

插入图片的两种方式

  1. 放到 source/img/ 下,正文写 ![说明](/img/xxx.png);
  2. 开启 post_asset_folder: true(_config.yml),文章会带同名资源文件夹,正文写 ![说明](xxx.png)。

常用 Markdown 扩展(Solitude 已支持)

  • 代码块:三反引号 + 语言名,如 ```bash
  • 提示块:暂时用普通的引用 > 提示 即可
  • 数学公式:$E=mc^2$(需要在主题配置里开启 katex)
  • 图片点开看大图:主题配置里开启 fancybox 或 mediumZoom