I have a lot of notes in separate files that I'd like to put on a hugo website using ox-hugo. However I can't seem to batch export the files.

I've tried:

  • using dired+ to execute diredp-do-apply/eval
  • using emacs --batch --eval "(progn (require 'org) (require 'ox-hugo) (org-hugo-export-wim-to-md))" "$@".

In both cases I get the message

The entire file is attempted to be exported, but it is missing the #+title keyword

which makes no sense to me since there are #+TITLE: title lines in each of the files and they export fine when visiting them in an emacs buffer using the same function.

Any help as to what I'm doing wrong is appreciated.


Using this dired snippet will do fine with single post files.

(define-key dired-mode-map (kbd "C-+") 
        (diredp-do-apply-function 'org-hugo-export-wim-to-md '(4))))

Universal argument is required because org-hugo-export functions works only in current buffer, so visiting the file is required. If not what I do understand from documentation is that you're operating on filename.

But if the visited buffer contains subtrees with posts org-hugo-export-wim-to-md will require arguments to adapt its behavior which you cannot pass this way.

(org-hugo-export-wim-to-md t)

So it seems that if your goal is to export automagically any kind of possible content, or your needs doesn't fall into non-arguments dwim (mines don't), you'll have to write your own routine invoking org-hugo-export-wim-to-md with the right optional arguments for the case.

  • no - the issue is that I have a directory of files that I'm trying to export each file as one post (whether or not that file consists of one or more trees/subtrees).
    – mclear
    Apr 13 '20 at 4:58
  • oh, misunderstood the issue. I'll edit the response.
    – Muihlinn
    Apr 13 '20 at 7:00
  • I had to change the function slightly to make it work: (define-key dired-mode-map (kbd "C-+") (lambda() (interactive) (diredp-do-apply/eval 'org-hugo-export-wim-to-md '(4))))
    – mclear
    Apr 13 '20 at 17:09
  • my diredp doesn't have that function, but it could be well outdated as I haven't spent enough time fixing some troubles it causes in my config. Anyhoo, glad to have been useful.
    – Muihlinn
    Apr 13 '20 at 17:24
  • yeah - perhaps it is a recent addition. I'm running the most recent version I think. Thanks!
    – mclear
    Apr 13 '20 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.