From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chunyang Xu Subject: Re: org to static site? Date: Thu, 01 Jun 2017 01:05:04 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG73n-0007u7-PA for emacs-orgmode@gnu.org; Wed, 31 May 2017 13:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG73k-0007Rk-Gr for emacs-orgmode@gnu.org; Wed, 31 May 2017 13:05:27 -0400 Received: from smtpbg65.qq.com ([103.7.28.233]:20725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG73j-0007Nv-Sm for emacs-orgmode@gnu.org; Wed, 31 May 2017 13:05:24 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price , Org Mode Matt Price writes: > I'm trying to wean myself off of Wordpress for next year's teaching > websites, and am wondering what solutions other people are using for > turning a collection of org pages and/or subtrees into a static html site. > I am leaning towards Hugo but honestly not for any sensible reason; I've > seen other people use Jekyll, though the fact that Github doesn't support > direct conversion from org-mode removes some of Jekyll's appeal; and I know > there are a number of other solutions too. > > So, I would love to hear what you all recommend. It is said that Nanoc is flexible. You can convert org mode to HTML with Pandoc or Emacs. Nanoc supports Pandoc out of box. To use Emacs, you need to write your own "filter" (Nanoc's terminology, i.e., convert one format into another), for example, #+BEGIN_SRC ruby require 'tempfile' class OrgFilter < Nanoc::Filter identifier :org def run(content, params = {}) file = Tempfile.new(['nanoc', '.org']) file.write(content) file.close system("emacs --batch --load init.el #{file.path} --eval '(org-html-export-to-html nil nil nil t)'") html = "#{File.dirname(file.path)}/#{File.basename(file.path, '.org')}.html" file.unlink File.read(html) end end #+END_SRC I just created my own site with it last week. The syntax highlighting on code block is provided by htmlize.el. I noticed `org-html-export-to-html' produces different HTML every time even the org file is unchanged at all. It is very annoying to me. I found a work-around to avoid it, #+BEGIN_SRC emacs-lisp ;; -*- lexical-binding: t; -*- (let ((id 0)) (defun org-export-new-reference--use-persistent-id (references) (let ((new id)) (while (rassq new references) (setq new (incf id))) new))) (advice-add 'org-export-new-reference :override #'org-export-new-reference--use-persistent-id) #+END_SRC [...] -- Org mode version 9.0.7 (release_9.0.7-496-g3d3e24 @ /Users/xcy/src/org-mode/lisp/)