17.16.2 The capture protocol

Activating the “capture” handler pops up a ‘Capture’ buffer in Emacs, using acapture template.

emacsclient "org-protocol://capture?template=X&url=URL&title=TITLE&body=BODY"

To use this feature, add a bookmark with an arbitrary name, e.g., ‘Org: capture’, and enter this as ‘Location’:

javascript:location.href='org-protocol://capture?' +
      new URLSearchParams({
            template: 'x', url: window.location.href,
            title: document.title, body: window.getSelection()});

You might have seen another expression:

javascript:location.href='org-protocol://capture?template=x'+
      '&url='+encodeURIComponent(window.location.href)+
      '&title='+encodeURIComponent(document.title)+
      '&body='+encodeURIComponent(window.getSelection());

It is a bit more cluttered than the former one, but it is compatible with previous Org versions 9.0-9.4. In these versions encoding of space as “+” character was not supported by URI decoder.

The capture template to be used can be specified in the bookmark (like ‘X’ above). If unspecified, the template key is set in the variable org-protocol-default-template-key. The following template placeholders are available:

%:link          The URL
%:description   The webpage title
%:annotation    Equivalent to [[%:link][%:description]]
%i              The selected text