6

I would like have a menu created from the directory structure of the org files created as a html menu that is inserted at the top of each html file. I know I can generate a sitemap that spans multiple files, so the required parsing is done anyway, but what about a menu in each file?

Let's say I have a directory structure like this:

|- News.org
|- Stuff.org
|- Coding
   |- Emacs.org
   |- Lisp.org

I would like that all four html files that are generate have a menu that says "News - Stuff - Coding", and if coding is selected, there is a submenu that says "Emacs - Lisp".

The styling of the menus is not important here, but is it possible to produce something like this (that can then be styled via css)?

1
3

OK, I dug some more into this. As far as I can see there are two possibilities of achieving this. Both rely on the autogenerated sitemap of org-publish-project. So setting :auto-sitemap t in the org-publish-project-alist is a prerequisite and in this example I set :sitemap-filename "sitemap.org".

The first possibility relies on org's include facility. Adding

#+HTML: <div id="navigation">
#+INCLUDE: "sitemap.org" :lines "3-"
#+HTML: </div>

will include the generated sitemap. The :lines "3-" ensures that the title of the sitemap is not included. You will need to create an empty file of the same name (if it does not already exist), so that you won't get a "Cannot include file" error on the first run. The output will only be correct after two runs of org-publish-project, as the sitemap needs to be built during the first run.

This approach has the disadvantage of including the menu in the body of the html, so it will always appear after the preamble.

Thus, the second approach uses :html-premble of the org-publish-project-alist. Here, you need a functions that exports the sitemap.org to html, using the "body only" option, reads the generated html file and returns it, wrapped in anything else that is required in the preamble.

2

HTML/css files can be included using #+html_head:. This gets rather messy, if you have a significant amount of customization, so these can be put in a separate file and included with #+setupfile:. Even better, there are a number of themes that have been put together so you don't have to go through the details yourself.

https://github.com/fniessen/org-html-themes has some very nice ones.

2
  • 1
    Well, I know all of that, but it doesn't answer my question. – Flash Dec 13 '15 at 7:06
  • I didn't realize you want separate files. Well, if you've read over that link at this point it seems like just a matter of html coding. – user2699 Dec 13 '15 at 7:38

Your Answer

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

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