By using this awesome emacs packages:
emacs-easy-hugo
: https://github.com/masasam/emacs-easy-hugoox-hugo
: https://ox-hugo.scripter.co/
I am now able to use emacs to write blog posts without the burden of the heavy-weighted wordpress, although my current workflow still has room to improve.
One thing I notice is that Hugo does accept .org
file as blog post (and it has less pain than .md
file, in terms of mathemtical equation typing). With that, it seems that ox-hugo
is not very useful in my case.
Current workflow
- Use
M-x easy-hugo
+n
(oreasy-hugo-newpost
) to create a new post (end with.org
). - To preview the post, run
hugo server -D
in terminal and monitor http://localhost:1313/. - To deploy the site in production (publish online), simply run
easy-hugo-publish
, it shall sync with my server and update load every incrementally (as is advertised inrsync
).
Tweak on deploy
Option 1 — rclone
An easy but not semi-automatic way to deploy will be using rclone
(my first attempt). To do so, we need two steps:
publish the site (on your local machine), one need to run
> hugo
This will "compile" org files into htmls, the final result will be at
public
folder under the hugo base folder).To deploy the site (publish online), we can run
> rclone public myserver:remote/folder/to/hugo/
where you need to specific myserver in your
~/.ssh/config
file.
Option 2 — rsync
Yet easy-hugo does have a routine called easy-hugo-publish
, which relies on rsync
. To enable using rsync
, we need to
Install rsync on server side by
$ apt install rsync
- Install the correct version of rsync and ssh, that is cwrysnc. https://itefix.net/cwrsync. After installation, we need to ensure that
PATH
is set correctly so thatrsync
andssh
are both using the ones fromcwrsync
. - To reduce ssh login, I need to
ssh-keygen
the RSA key and copy the public key to theauthorized_keys
on remote~/.ssh/
folder. - Modify the
easy-hugo.el
Line 707. Functionshell-quote-argument
is actually not suitable for Windows user. After modifying the code, we need to runM-x byte-compile
to compile the lisp code.
Configuration in .emacs
(use-package easy-hugo
:ensure t
:init
(setq easy-hugo-basedir "path/to/your/local/hugo/folder/")
(setq easy-hugo-url "http://URL/to/your/remote/hugo/site/")
(setq easy-hugo-sshdomain "your_remote_server_domain_name")
(setq easy-hugo-root "path/to/your/remote/hugo/folder/")
(setq easy-hugo-previewtime "300")
(setq easy-hugo-default-ext ".org")
(setq easy-hugo-org-header t)
(define-key global-map (kbd "C-c C-e") 'easy-hugo)
)