I'm trying to use the following property value in org-publish-project-alist

:html-divs ((preamble "header" "preamble")
            (content "main" (org-export-output-file-name))
            (postamble "footer" "postamble"))

to make the value of the id attribute of the main element the name of the org file. For example, <main id="index">. However, the actual HTML output is the literal function call: <main id="(org-export-output-file-name)">.

The documentation for org-export-output-file-name says,

Return file name as a string.

  • Although the specifics of this question are different, the general question has been asked before and answers abound. You can search for backquote or quasiquote here or in the emacs lisp manual. Here is a link that should help. – NickD Apr 26 at 20:02
  • @NickD thank you, (setq org-html-divs <backquote>((preamble "header" "preamble") (content "main" ,(file-name-base (org-export-output-file-name ".html"))) (postamble "footer" "postamble"))) works perfectly outside of org-publish-project-alist but not as the value of its :html-divs property. So the id value is the filename that contains the preceding, that is <main id="publish-archilutes">, but not the exported html file, for example index. – user28706 Apr 27 at 0:37
  • Sorry, you are right (IIUC which apparently is a big if): I was assuming that org-export-output-file-name would be able to furnish the required name at the time of the setq but it can only do that at the time that org-publish is called and processes the files to be published. – NickD Apr 27 at 1:21
  • @NickD no problem, this has been helpful! Is the filename available as a variable? I can post a separate question if that's preferred. – user28706 Apr 27 at 1:43
  • No, I think it's constructed during exporting/publishing, so it is not available until that time. I don't think there is a need for a new question. I'll check how :html-divs is used at some point, but the discussion here should allow somebody else to pick up the stick and run with it. – NickD Apr 27 at 18:28

Your Answer

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