Usage question #24

priyadarshan opened this Issue Jun 21, 2012 · 8 comments


None yet

2 participants



We need to publish a library of about 1300 books (1 org-mode file per book), as a static site. Each book would have its own subdirectory, and each chapter its own page, linking to the proper book TOC, and the previous/next page. The total number of pages is more or less 120,000 pages.

As first attempt, we tried to use org-jekyll (by Jose Reyero,, after having tried other solutions, like org2jeklyll ( etc.).

Right now, Emacs converts the pages to HTML files, and Octopress generates the static site.

We are not satisfied with this solution for many reasons, though, and we are still searching for a way to manage everything from Emacs (without having to learn ruby, liquid templating, etc).

I am going to try out o-blog in any case, for other sites as well, but I would like to ask if you feel it would be practical to use it also for our Library project, considering that site does not have a blog proper, but only a flat hierarchy of about 1300 sibling subdirectories?

How easy it would be to add custom features, like, for example:

  • previous/next links
  • a proper TOC for each book
  • an alphabetised index (divided by letter) for all the titles

Thank you so much for your excellent code!


Hi again,

I have seen that a v2 is in the making ( Does that mean multimarkdown is going to be the focus of o-blog in the future (more than org-mode syntax), or multimarkdonw will be just an extra syntax option added, beside org-mode syntax?

renard commented Jun 21, 2012


The principle of o-blog is to generate (by default) articles sorted by date. Of course you can still write a book by the use of:

* DONE Chapter title
  CLOSED: [2012-06-21 Sat 17:43]

Chapter content

Just be sure your chapters are correctly timestamped.

On the other hand you can customize ob-parse-entries (which use ob-sort-posts-by-date) to use a custom function.

Maybe a better idea you be to create a customizable function call such as done for the filename-sanitizer option.
Then you might be able to add a custom org property such as CHAPTER_ID or something like that and sort against that criteria.

Once your chapters are sorted as you would be able to navigate using prev/next links.

The TOC can be specified like the archives (you might need to adapt some templates for that).

The alphabetized index can be done using tags.

Regarding the V2, you are right I plan to use some other markdown systems (asciidoc as first milestone). Then you would be able to publish from several systems. But this is a very early though and I don't have any release plan for the moment.

If your work is in public domain or is you don't mind to send me a book sample I would be glad to test your publication needs since it would be a good POC for o-blog universal use.

Thank you for your interest in o-blog.

renard commented Jun 21, 2012


You can check the 748b336 commit. You can write you own function to sort the posts.

You can do something like:

#+POST_SORTER: my-custom:ob-sort-posts-by-title
(defun my-custom:ob-sort-posts-by-title (a b)
  "Sort alphabetically both A and B posts by title."
  (string> (ob:post-title a)
       (ob:post-title b)))

If your work is in public domain or is you don't mind to send me a book sample I would be glad to test your publication needs since it would be a good POC for o-blog universal use.

Thank you so much for all your help and advice. We would be so grateful if we could use o-blog to manage and publish that library. To give you an idea, I have put a book sample here:

A brief history: each book (in the present collection) started as ReStructuredText file. We then briefly considered Markdown, but when we saw how perfectly org-mode syntax is able to cover each book's meta-data needs, we decided to convert the whole Library to org-syntax.

We do have the requirement to keep all metadata only as properties (no TAGS), and to keep them only if related to the content (ie to avoid adding metadata related to presentation, or publication logic). It would not be good for us to have to add too many properties that add content alien to the author's original work (like HTML or LaTeX snippets, etc).

Also to use something like:

* DONE Chapter title CLOSED: [2012-06-21 Sat 17:43]

would not be too good, since it 'pollutes' the Author's original work with our own (presentation or logic) internal meta-data.

You will notice that each chapter has a UNIT number. The first page (not properly part of the Author's work) is UNIT 0000.

Ideally, when that book is published:

  • it should reside at
    (the-vedas-immortalitys-first-call is the FOLDER property)
  • it should have its TOC at
    If there is any text at UNIT 0000 (the first heading) then, that text should precede the TOC programmatically created at publish time.
  • each of its pages should be of the form:
  • each page should have a link to the TOC page, a link to the previous sibling (if exists) and a link to the next sibling (if exists).


  • There is no need for any date, like it would for a blog, either in the url, nor on the page. Dates are dealt like normal text.

Just to complete the use case, the Alphabetical index should be located at and present a sorted list of initials. If the user clicks on, say, letter V, he would see a sorted list of book with title starting with V, each title a link to the respective book. We have the property SORT-TITLE for that.

Note that the sample book has only 8 chapters (7+index/TOC), but, for example, we have a series of 50 poetry books that have 1000 chapters each (so those 50 subdirectories would contain 1001 files each).

I would be so grateful if you could give us some directions on how to deal with this setup. I am an absolute beginner in the elisp world, but, having seen how amazingly powerful it is, especially in text manipulation, I am eager to learn as much as I could, possibly without bothering you too much!

Thank you.

PS: I will be traveling until Sunday. I shall be available online from Monday on.

renard commented Jun 25, 2012


I changed a little bit the functionality to allow you to create your own output functions. Thus

Thus if at the top of the you add:

#+POSTS_FILEPATH: ob-set-flat-filepath
#+POSTS_HTMLFILE: ob-set-flat-htmlfile
#+POSTS_SORTER: ob-sort-posts-by-unit

you would be able to generate what you want.


Would take all entry with a UNIT property for a chapter.

#+POSTS_FILEPATH: ob-set-flat-filepath

You need to define a function like:

(defun ob-set-flat-filepath (category year month)
  (ob:sanitize-string (org-entry-get (point) "SOURCE")))

You don't need category, year nor month but you want the SOURCE property to be used as root directory for you book.

#+POSTS_HTMLFILE: ob-set-flat-htmlfile

You need to define a function like:

(defun ob-set-flat-htmlfile (filepath day filename)
  (format "%s/%s.html" filepath filename))

Here you want to use the chapter title as html file.

#+POSTS_SORTER: ob-sort-posts-by-unit

You need to define a function like:

(defun ob-sort-posts-by-unit (a b)
  "Sort both A and B posts by unit number."
  (let ((ua (with-temp-buffer
         (insert (ob:post-content a))
         (goto-char (point-min))
         (org-entry-get (point) "UNIT")))
    (ub (with-temp-buffer
         (insert (ob:post-content b))
         (goto-char (point-min))
         (org-entry-get (point) "UNIT"))))
  (string< ub ua)))

Here you do sort posts against their UNIT property.

Please note that this is a quick and dirty first try. You might need to update some templates to feet what you need.



Thank you so much for the new code! It seems a very elegant solution. I am testing it and I will report back (I will need a couple of days though).

renard commented Jun 26, 2012

Ok no problem. Please do not forget to close the issue :-)


Oh, sorry, the ticket can be closed now, although I am sure I will have a few more questions in a few days regarding this new feature :)

Thank you so much for the truly excellent elisp app. I am learning many things from it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment