Blogging from Org-mode: 2016 edition

There are a few tutorials on setting up org2blog with WordPress blogs, but many of them are outdated and don’t yet use use-package.

Setup your .netrc

Open (or create an empty) ~/.netrc file and save you credentials.
The content of my file:

# machine machine-name login some-login password some-password

machine suboptimum login YOURNAME1 password PASSWORD1
machine thraxys login YOURNAME2 password PASSWORD2

I have two blogs, hence 2 lines. The meaning of the fields is simple:

  1. machine name – an arbitrary string identifying your blog (needed later in the config).
  2. YOURNAME – this has to be your WordPress “User Name” (see your Account Settings)
  3. YOURPASSWORD – your WordPress password…

If you have multiple blogs under the same WordPress account, the PASSWORD and YOURNAME string will be the same for all of them.


Configure org2blog

Here is how you configure org2blog and its prerequisites via use-package.
It can support multiple blogs, if you have only one, just remove the 2nd

(use-package xml-rpc
:ensure t
:defer t)

(use-package netrc
:ensure t
:defer t)

(use-package org2blog
:ensure t
:defer t
(let (credentials)
(add-to-list 'auth-sources "~/.netrc")
(setq credentials-thraxys (auth-source-user-and-password "thraxys"))
(setq credentials-suboptimum (auth-source-user-and-password "suboptimum"))
(setq org2blog/wp-blog-alist
:url ""
:username ,(car credentials-thraxys)
:password ,(cadr credentials-thraxys))
:url ""
:username ,(car credentials-suboptimum)
:password ,(cadr credentials-suboptimum))


Start a normal org-file and you can use M-x org2blog/wp-post-buffer to post the full buffer or M-x org2blog/wp-post-subtree to post just the current subtree (part under heading).

“Posting” means that it will go to your WordPress drafts, where you can check and edit it.

If you have multiple blogs, you’ll be asked to which one you want to send it. Alternatively you can use org2blog/wp-login to login to one of them.

There are also *-and-publish versions of the commands, that directly publish the entry.



Unfortunately, org2blog is somewhat dormant and I’ve run into one issue and one annoyance.

The issue: first time posting after installation via use-package, you’ll might get an error:

“org-export-as: Wrong number of arguments: #[(templates) ” and some garbage characters.

What worked for me is to cd into your elpa directory and remove the org folder (this was an independent org “installation” created during the org2blog install – not my actual org instance).

After restart I had no longer issues.
Also see here, here and here (even if you don’t use spacemacs – I don’t).

The minor annoyance is, that org2blog splits the window during *-post commands (noted also here, see there a simple workaround too).

This post (as well as a few previous ones) has been written in org-mode.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s