DEV Community


Posted on • Originally published at on


Blogging with Emacs and WordPress


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:

  1. Use org-capture to create a new file of org-mode
  2. Edit the post
  3. 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 ()
    (let ((name (concat (format-time-string "%Y_%m_%d_")
                        (read-string "file-name: "))))
      (expand-file-name (format "" 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/")
         "** TODO %?\n %i\n " :empty-lines 1)
        ("b" "Blog file" entry (file create-blog-file)
         "** New Post\n#+BLOG:\n#+CATEGORY:\n#+TAGS:\n#+DESCRIPTION:\n#+ATTR_WP: :syntaxhl light=true\n#+TITLE: %^{desc}\n " :empty-lines 1)

Enter fullscreen mode Exit fullscreen mode

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 ()
  (let* ((path (concat default-directory "img/"))
         (image-file (concat
                      (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) ""))

Enter fullscreen mode Exit fullscreen mode

The post Blogging with Emacs and WordPress appeared first on CodersCat.

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.