I have a project with a few org files that are exported as HTML to create a website. All org files that correspond to web pages have #+SETUPFILE: my-setup.org declared in it. And the my-setup.org file have all the common settings like the following.

#+language: en
#+html_doctype: html5
#+html_head: <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />

Is there a way I can declare an HTML preamble content in the my-setup.org, so that it is applied to all the exported webpages.

I have already tried using the following solution from another question, and it doesn't work when added to my-setup.org.

# Local Variables:
# org-html-preamble: "My custom preamble!"
# End:

I don't want to add this preamble to my ~/.emacs.d/init.el file where I have the org-publish-project-alist configured, as this preamble should be part of the project repo.


1 Answer 1


Try creating a file .dir-locals.el in the top-level directory of your project hierarchy and adding this content to it:

((org-mode . ((org-html-preamble . "My custom preamble!"))))

See Per-Directory Local Variables in the Emacs manual.

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.