Inside the current buffer
The simplest way is to create a function that does those two things for you.
When you press (
C-c C-e h h) the function
org-html-export-to-html is run
in the current buffer.
When you press (
C-c C-v t) the function
org-babel-tangle is run in the
Therefor you can use the following function to do both for you:
(defun export-tangle ()
"Shortcut for exporting and tangling the current org-mode buffer."
You can then bind this function to
(local-set-key (kbd "M-<f2>") 'export-tangle)))
In a script
Sometimes you want to do this on files instead of the currently open buffer.
You can then create a similar function that opens the file for you and runs
the functions for you:
(defun export-tangle-file (filepath)
"Shortcut for exporting and tangling the org-mode file at `filepath'."
(find-file (expand-file-name filepath))
You can then use that function in a script for example. Like this:
For all files in a directory
You can even setup org-mode to publish and tangle a whole directory tree full
of org-mode files for you using the setting
Some people use this to write blogs in org-mode and then publish the whole
blog using (
C-c C-e P p).
org-publish-project-alist you create components that does different
types of publishing.
Here's an example of how you can set up copying static assets, publishing
org-mode articles and tangling org-mode articles:
:components ("assets" "tangles" "articles"))))
org-table-tangle-publish will put all tangles in the root of the
So if you have setup tangling with a directory structure, it will be flattened.
I also encountered an error when the directory
publish-directory didn't exist.
After creating the directory it worked.