0

I'd like my exports to go into a specific directory. Right now everything is output in the same path as the source file.

There's a very old post with sample code that seems get me part way there:

 (defun org-export-output-file-name-modified (orig-fun extension &optional subtreep pub-dir)
    (unless pub-dir
      (setq pub-dir "exported-org-files")
      (unless (file-directory-p pub-dir)
        (make-directory pub-dir)))
    (apply orig-fun extension subtreep pub-dir nil))

 (advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)

However HTML exports don't include images, either static ones or inserted via PlantUML. Latex/PDF export works fine though.

Is there a better option?

Edit:

I tried the following org-export code:

    (require 'ox-publish)
    (setq org-publish-project-alist
          '(("org-notes"
             :base-directory "~/Dropbox/orgmode/"
             :publishing-directory "~/export"
             :publishing-function org-html-publish-to-html
            )

            ("org-static"
             :base-extension "png"
             :base-directory "~/Dropbox/orgmode/"
             :publishing-directory "~/export"
             :publishing-function org-publish-attachment
             )

            ("org" :components ("org-notes" "org-static"))

            )
          )


The images are not being moved to ~/export though.

Edit 2:

Apologies for the paths; I fixed them now. So the issue seems to be Babel and plantuml. I have the following org-file:

#+title: org-export-test

* Meta                                                            :noexport:

Meta section. We don't expect to see it exported due to the ~noexport~ tag.

* Intro

This is an intro section.



* Plantuml section

What we store.

#+begin_src plantuml :file plantuml_dirgram.png

  @startuml
  hide circle
  skinparam linetype ortho

  entity "Table" as EventLog {
          id : number <<generated>>
          --
  }
  @enduml
#+end_src

The PlantUML section contains a directive to output to plantuml_diagram.png in the same path as the org file.

However when I run org-publish-current-file, the HTML file is generated, but the png is not. If I generate the png file manually into ~/Dropbox/orgmode, it's still not copied into ~/export.

7
  • 1
    That's because you can't just move the HTML file: all the images (etc) that are linked from the HTML file have to be moved as a unit, OR the export has to be modified to produce different URLs for the links. However, the method that is built-in to Org mode is Publishing: publishing is essentially exporting + moving files to a publishing directory - you have to write a (for simple cases, small) config file (there is an example in the manual) but it works very well.
    – NickD
    Feb 24, 2022 at 17:31
  • @NickD I updated the question with org-publish functionality, but still no luck. I don't see any errors or anything useful in Messages. toggle-debug-on-error is set as well. Feb 24, 2022 at 18:52
  • ~/export? You mean ~/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/org-roam/export?
    – NickD
    Feb 24, 2022 at 18:56
  • 1
    Start with a small example with images and the "complex" config file example (which is pretty simple really). Make sure you use relative path names in the Org mode links. I presume you got the config file from the publishing tutorial on Worg. Where are your images kept in relation to your Org mode files? See the discussion about directory hierarchies in the tutorial. At least at first, make sure that you stay very close to the tutorial and double-check all the settings.
    – NickD
    Feb 24, 2022 at 19:07
  • 1
    I will but it's not going to be immediate. Maybe at the end of the week...
    – NickD
    Mar 21, 2022 at 16:44

1 Answer 1

0

I figured it out. I was using M-x org-publish-current-file which does not respect project settings. As soon as I switched to M-x org-publish-current-project or C-e P x the export worked as expected.

1
  • 1
    There is something more to this I think: org-publish-current-file uses org-publish-file, the same function that is called from org-publish-current-project, so it most certainly respects project settings. I suspect there is something going on with the cache, but I'm not sure (and I don't have time to check now).
    – NickD
    Mar 22, 2022 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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