UP | HOME

Publishing with Org

Table of Contents

Press m to reveal the entire page or ? to show all shortcuts.

1. Major inspiration

https://pavpanchekha.com/blog/org-mode-publish.html

The basic idea is to establish the patterns to be published from the source directories and to designate a place to publish. The layout is described most readily in an elisp file. An example is given here:

(setq my-src-dir (expand-file-name "~/Documents/doc/"))
(setq my-pub-dir "/Users/saeta/Sites/doc/")
(setq org-publish-use-timestamps-flag t)
(setq org-publish-project-alist
  `(
    ("website" :components ("orgfiles" "images" "static"))

    ("orgfiles"
      :base-directory ,(concat my-src-dir "org/")
      :publishing-directory ,(concat my-pub-dir "html/")
      :base-extension "org"
      :publishing-function org-html-publish-to-html
      :headline-levels 3
      :section-numbers t
      :with-toc t
      :with-creator nil
      :auto-sitemap t
      :sitemap-filename "index.org"
      :sitemap-title "Documentation"
      :html-head "<link rel=\"stylesheet\" href=\"../static/doc.css\" type=\"text/css\"/>"
      :html-preamble t
      :options ':t               ;; curly quotes
      :language en
      :html-link-home "index.html"
      :html-link-up "index.html"
      :author "Peter N. Saeta"
      :email "saeta@hmc.edu"
      :recursive t
    )

    ("images"
      :base-directory ,(concat my-src-dir "img/")
      :publishing-directory ,(concat my-pub-dir "img/")
      :base-extension "jpg\\|gif\\|png\\|jpeg"
      :publishing-function org-publish-attachment
      :recursive t)

    ("static"
      :base-directory ,(concat my-src-dir "static/")
      :publishing-directory ,(concat my-pub-dir "static/")
      :base-extension "css\\|js"
      :publishing-function org-publish-attachment
      :recursive t)
  )
)

Unfortunately, I don't know how to make automatic index files at the appropriate depths in the hierarchy. However, it is possible, at least, to get the UP | HOME links to function properly by including a line such as the following at the top of the file:

#+title: Whatever title you need
#+setupfile: ~/.emacs.d/org-templates/level-1.org
#+include: ~/.emacs.d/org-templates/keys.org

I have generated a suite of *setupfile*s in the indicated directory, which provide a number of local configurations, the most significant of which is setting the UP and HOME links properly, and the html_head field, that loads the site's style sheet. Here's an example:

user$ cat ~/.emacs.d/org-templates/level-1.org
#+options: ':t *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline author:t
#+options: broken-links:nil c:nil creator:nil d:(not "LOGBOOK") date:t e:t
#+options: email:nil f:t inline:t num:t p:nil pri:nil prop:nil stat:t tags:t
#+options: tasks:t tex:t timestamp:t title:t toc:t todo:t |:t
#+options: html-link-use-abs-url:nil html-postamble:auto html-preamble:t
#+options: html-scripts:t html-style:t html5-fancy:t tex:t
#+html_doctype: xhtml-strict
#+html_container: div
#+infojs_opt:
#+creator: <a href="https://www.gnu.org/software/emacs/">Emacs</a> 25.3.50.1 (<a href="https://orgmode.org">Org</a> mode 9.3.6)
#+html_head: <link rel="stylesheet" href="../../static/doc.css" type="text/css">
#+html_link_home: ../index.html
#+html_link_up: index.html

Author: Peter N. Saeta

Created: 2022-09-16 Fri 21:18

Validate