由于日常主力的编辑器是 Emacs,通过 hugo 维护站点也都是在 Emacs 里面完成。自然的,希望写博客的工作流能够融合进 Emacs 的使用当中。于是,找到了 Easy-hugo 这个工具。

安装 Easy-hugo

Easy-hugo 的安装与配置都比较简单,官方文档都说的比较清楚了。由于我目前使用的是 Purcell 的Emacs 配置,可以通过下面的配置安装:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(when (executable-find "hugo")
  (when (maybe-require-package 'easy-hugo)
    (global-set-key (kbd "C-c b") 'easy-hugo)
    
    (with-eval-after-load 'easy-hugo
      (setq easy-hugo-default-ext ".org")
      (setq easy-hugo-url "https://eason0210.github.io")
      (setq easy-hugo-basedir "~/website/eason0210.github.io/")
      
      (unless (file-exists-p easy-hugo-basedir)
        (make-directory easy-hugo-basedir)))))

使用 Easy-hugo

平时需要写博客的时候就按 C-c b 启动 easy-hugo 的界面。

  • n 新建 post,编辑完成后, C-c b , p 进行预览,效果满意的话,直接 C-x g 启动 Magit 进行提交,GitHub Action 会自动启动 CI 进行构建更新网站内容。
  • 觉得 post 的名称取得不够好,需要重新命名,可以按 R ,然后输入新的名字对当前光标所在的 post 进行重命名。
  • 搜索 post, f 选择 post 名称,如果使用 vertico + orderless 效果会更好。
  • 删除 post, d 删除不需要的 post。

Easy-hugo 的大部分功能目前对于我来说暂时是用不到的。

2021-09-20 更新:目前已经不再使用 easy-hugo, 因为写博客并不是很频繁,而且 easy-hugo 在预览时经常需要重启,还不如直接在终端中执行 hugo server -D 更方便。

Easy-hugo 的按键绑定列表

keyfunction
RETeasy-hugo-open
Tabeasy-hugo-full-help
Shift-Tabeasy-hugo-no-help
SPCeasy-hugo-next-line
Shift-SPCeasy-hugo-previous-line
easy-hugo-backward-char
easy-hugo-forward-char
C-beasy-hugo-backward-char
C-feasy-hugo-forward-char
C-neasy-hugo-next-line
C-peasy-hugo-previous-line
M-beasy-hugo-backward-word
M-<easy-hugo-beginning-of-buffer
.easy-hugo-next-postdir
,easy-hugo-previous-postdir
+easy-hugo-next-postdir
/easy-hugo-select-postdir
;easy-hugo-select-blog
<easy-hugo-previous-blog
>easy-hugo-next-blog
?describe-mode
!easy-hugo-cancel-firebase-deploy-timer
Aeasy-hugo-amazon-s3-deploy
Beasy-hugo-firebase-deploy
Ceasy-hugo-google-cloud-storage-deploy
Deasy-hugo-list-draft
Feasy-hugo-full-help
Geasy-hugo-github-deploy
Heasy-hugo-github-deploy-timer
Ieasy-hugo-google-cloud-storage-deploy-timer
Jeasy-hugo-nth-blog
Leasy-hugo-firebase-deploy-timer
Measy-hugo-magit
Neasy-hugo-no-help
Oeasy-hugo-open-basedir
Peasy-hugo-publish-clever
Reasy-hugo-rename
Seasy-hugo-sort-char
Teasy-hugo-publish-timer
Veasy-hugo-view-other-window
Weasy-hugo-amazon-s3-deploy-timer
aeasy-hugo-ag
beasy-hugo-cancel-github-deploy-timer
ceasy-hugo-open-config
deasy-hugo-delete
eeasy-hugo-open
feasy-hugo-select-filename
geasy-hugo-refresh
heasy-hugo-backward-char
ieasy-hugo-cancel-google-cloud-storage-deploy-timer
jeasy-hugo-next-line
keasy-hugo-previous-line
leasy-hugo-forward-char
measy-hugo-cancel-amazon-s3-deploy-timer
neasy-hugo-newpost
oeasy-hugo-open-other-window
peasy-hugo-preview
qeasy-hugo-quit
reasy-hugo-refresh
seasy-hugo-sort-time
teasy-hugo-cancel-publish-timer
ueasy-hugo-sort-publishday
veasy-hugo-view
weasy-hugo-newpost