Hexo and Jekyll are good, but…
I write about programming, technology, and other topics.
10 years ago, I started blogging with WordPress and then transferred to Jekyll several years later, then continually moved to Hexo.
Jekyll and Hexo are fascinating tools for programmers to generate content files into the HTML page. We only need to publish generated results onto a server.
The generated pages are minimized and super fast. We can use Git or any other version control tools to manage posts.
In one word, with these tools we can blog like coding, it’s the style of programmers.
Blogging with Emacs and WordPress
I begin this new blog recently, for practicing another style of writing: writing for others.
However, I realized recently, WordPress is still a good choice for technical blogging.
WordPress is the most popular tools for building a site, it’s more than 20 years old and with many existing good plugins.
Org2Blog is amazing
I have used org-mode for about 2 years. I won’t change to write on the dashboard of WordPress. Org2Blog is the reason I want to use Emacs for blogging. The experience of writing in org-mode is amazing.
The whole workflow is:
- Use
org-capture
to create a new file of org-mode - Edit the post
- Use the command
org2blog/wp-post-buffer-and-publish
to commit the post to WordPress.
Some handy configurations
This is my org=capture-templates
. All posts are stored in the directory: ~/Dropbox/org/blog/
, images are stored in a subdirectory of imgs
.
(defun create-org-file-with-dir (dir)
(lexical-let ((dir dir))
(lambda ()
(interactive)
(let ((name (concat (format-time-string "%Y_%m_%d_")
(read-string "file-name: "))))
(expand-file-name (format "%s.org" name) dir)))))
(defun create-blog-file ()
(funcall (create-org-file-with-dir "~/Dropbox/org/blog/")))
(setq org-capture-templates
'(("t" "Todo" entry (file+datetree "~/Dropbox/org/work.org")
"** TODO %?\n %i\n " :empty-lines 1)
("b" "Blog file" entry (file create-blog-file)
"** New Post\n#+BLOG: coderscat.com\n#+CATEGORY:\n#+TAGS:\n#+DESCRIPTION:\n#+ATTR_WP: :syntaxhl light=true\n#+TITLE: %^{desc}\n " :empty-lines 1)
))
It’s easy to insert code snippet use org-insert-structure-template
. Except for code, we can also insert various kinds of templates:
I wrote this elisp code org-insert-image
to insert image from clipboard:
(defun org-insert-image ()
(interactive)
(let* ((path (concat default-directory "img/"))
(image-file (concat
path
(buffer-name)
(format-time-string "_%Y%m%d_%H%M%S.png"))))
(if (not (file-exists-p path))
(mkdir path))
(shell-command (concat "pngpaste " image-file))
(org-insert-link nil (concat "file:" image-file) ""))
)
The post Blogging with Emacs and WordPress appeared first on CodersCat.
Top comments (0)