Org2Blog – Post to WordPress from Emacs

Post to WordPress from Emacs with org2blog

Org2Blog provides a way of synchronizing your Org mode document with a WordPress post or page.

Here are the top benefits of using Org2Blog:

  • Post and update WordPress content from within Emacs
  • Manage content locally
  • Speed up your workflow
  • Optimize content generation and publication

Org2Blog allows you to easily integrate your writing and publication workflow into one system. It starts with brainstorming. Org mode is designed to be the best outlining tool any text editor can offer, because it’s simple. You can organize your thoughts with bullets, which can be easily promoted, demoted, or re-arranged in different sequence — and all with a few quick keystrokes. Or, you can set out your thoughts as headings, which can also be organized according to a hierarchy. Once you’ve decided on everything you want to say, you can start to fill in words and paragraphs. Soon, you will see your document forming and expanding before your eyes. And with a few keystrokes you can publish your content to WordPress — without ever having to leave your Emacs window.

Org2Blog Requirements

For more information about the Org mode project, be sure to check out the official Org mode website.

Usage of Org2Blog requires only an understanding of the basics of Emacs, how to install packages, and a basic understanding of the mechanics of Org mode as a single-source authoring system. Your Org mode markup will be converted into HTML automatically and uploaded to your WordPress site. Of course, this means that having a WordPress site is the final requirement (but I would assume you already have one if you’re reading this article).

Org2Blog Installation

You can install Org2Blog manually by downloading the files and loading them into your Emacs configuration. But the easiest way to accomplish the installation is by using the Melpa package manager:

M-x package-install RET org2blog RET

Set Up Your Website

In order to connect your Emacs installation with a WordPress installation, you can use an Emacs Lisp expression like the one below:

(setq org2blog/wp-blog-alist
      '(
        ("blog"
         :url "https://example.com/xmlrpc.php"
         :username "username"
         :password "password")))

Using the same expression, you can add as many sites as you want. Like so:

(setq org2blog/wp-blog-alist
      '(
        ("blog"
         :url "https://example.com/xmlrpc.php"
         :username "username"
         :password "password")
        ("blog2"
         :url "https://example2.com/xmlrpc.php"
         :username "username"
         :password "password")

))

Note that each URL for each site ends with an /xmlrpc.php. This is because Org2Blog uses the xmlrpc.php file provided by your WordPress installation to:

  1. Open a connection
  2. Post your content

Media Management

Org2Blog can also upload images directly from your computer to WordPress. This means you don’t have to manually manage your media library. Be sure to store your images in a reliable location if you plan to use them later.

Enable image upload by adding this line to your Emacs init file:

(setq org2blog/wp-image-upload t)

To reuse an image, you can include it in another post just as you did before. Org2Blog will check to see if this image has already been uploaded, and if so it will use the remote version instead of uploading the file again. That way, you will not have duplicate images on your server.

Here’s an example for including an image with CSS styles and image attributes, followed by the file path to the file itself. This is all Org2Blog needs to include your image, upload it, and use it in the post. The following syntax will be converted to HTML:

#+ATTR_HTML: :class wp-block-image size-full 
#+ATTR_HTML: :alt Alt text goes here. 
#+ATTR_HTML: :align center
~/Pictures/image.jpg

More Resources On Managing WordPress

CM
Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+