I am using org-mode to generate html pages from my notes. I used Publishing Org-mode files to HTML to setup blog system.

I have defined an export template. But to use it I have to add following line in top of my every org file inside my notes project.

#+SETUPFILE: ~/.emacs.d/org-templates/level-0.org

Is there a way to set this up in .emacs or to customize an org-mode variable so that I do not have to place this line in every file?

According to org-mode manual, #+SETUPFILE is an in-buffer setting. Does this mean I cannot define it globally for all org files?

These two answers on SU tell how to customize style for HTML export. But my template file contains other settings besides CSS style. So only customizing style won't do it for me.

2 Answers 2


This is what I understand.

If you need to define settings globally, you should define Options for the HTML/LaTeX exporters in org-publish-project-alist inside .emacs.

#+SETUPFILE is to be used when you need to override global settings and define custom settings for few or a single file. If those settings are used frequently, you can define a template and use SETUPFILE to instruct org-mode to use the template to export this org file.

So I solved my problem by defining global settings in .emacs and dropped the idea of using a global template

     :author "Andy"
     :email "[email protected]"
     :language "en"
     :link_home "index.html"
     :style "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style.css\" />

You can add hook org-publish-before-export-hook with the function like

(defun my-add-setup ()
  "Insert SETUPFILE statement in the beginning of the buffer for export ONLY."
  (interactive) ; for testing in scratch
  (goto-char (point-min))
  (insert "#+SETUPFILE: ~/.emacs.d/org-templates/level-0.org\n")

P.S. I did not try it myself.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .