2

I am using org mode to write my personnal website. I use the workflow described in the documentation (cf. https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html) and I therefore have a converter.el file consisting, as in the link given above, of the definition of org-publish-project-alist with the notes and static components. I evaluate the whole buffer and run org-publish-project "org" everytime I want to export my files to HTML.

However, I use my own CSS files to style my webpage. For the moment, my files all have a variant of #+HTML_HEAD: <link rel="stylesheet" href="./css/style.css"/> in their first lines. This is totally functionnal and gives the expected graphical result as it allows me to use my own options. #+STYLE: ... is great too.

However, what I'm looking for is the following : I would like to have simple .org files with only the markup part and a unique "switch file" specifying for each of the .org file what style should be assigned, or more generally what are its options. This way, I would have a total separation between my writings (the .org files) and the configuration (this "switch file" plus the CSS files). I guess this file would have some kind of switch-loop structure (hence its name here) and should be used in convert.el, but I have no idea how to code it.

Anyone have any idea how to program it ? I've tried myself but I'm not really good at elisp. I've also searched the web for similar questions, but all the examples I've found always specify the style in the preamble of .org files... Any advice is welcome !

Drew
  • 75,699
  • 9
  • 109
  • 225
Wirius
  • 121
  • 1

1 Answers1

2

A useful option is to put

#+SETUPFILE: mysetup.org

at the top of each .org file and then place your common heading commands such as

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="mystyle.css" />

in the file mysetup.org. Note that mysetup.org can contain further #+SETUPFILE: lines, reading in other files.

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
  • Thank you very musch for your answer. However, I have multiple CSS files (let's say `style1.css` and `style2.css`) and I would like to have one setup file. Could it be possible to have one file `mysetup.org` containig some kind of switch structure to assign each .org file to its correct .css file ? I guess that kind of programming trick could be easily done in elisp, and I thus added _elisp_ in the flags, but someone removed it I don't know why... – Wirius Jan 31 '20 at 16:34
  • I am not really clear what your needs are. An alternative is to change the publishing alist with different settings for different groups of files, see e.g. the `:include` directive under "Selecting files" in the org mode documentation of "Publishing > Configuration" – Andrew Swann Feb 01 '20 at 16:57