Build

Script

(load-library "ox-thtml")
(setq mysite/name "Tiger Finch")
(setq mysite/email "t@anthonyfinch.com")
(setq mysite/dir "~/dev/anthonyfinch")

(defun my/org-publish-org-sitemap-format (entry style project)
  (cond ((not (directory-name-p entry))
         (if (org-publish-find-property entry :date project)
             (let* ((date (org-publish-find-property entry :date project)))
               (format "[[file:%s][%s %s]]"
                       entry
                       (org-timestamp-format (car date) "%Y-%m-%d")
                       (org-publish-find-title entry project)))
           (format "[[file:%s][%s]]" entry (org-publish-find-title entry project))
           ))
         ((eq style 'tree)
         ;; Return only last subdir.
          (file-name-nondirectory (directory-file-name entry)))
         (t entry)))

(defun my/org-publish-sitemap (title list)
  (concat "#+TITLE: " title "\n\n"
          (org-list-to-subtree list)))

(defvar html-extra-context nil "Should I show extra context?")

(setq org-publish-project-alist
      `(("posts"
         :base-directory ,(concat mysite/dir "/posts")
         :base-extension "org"
         :exclude "sitemap.html"
         :publishing-directory ,(concat "/tmp/build" "/posts")
         :htmlize t
         :publishing-function org-html-publish-to-templated-html
         :html-template ,(templated-html-load-template "templates/page.html")
         :recursive t
         :section-numbers nil
         :with-toc nil
         :author ,mysite/name
         :email ,mysite/email
         :auto-sitemap t
         :sitemap-filename "index.org"
         :sitemap-title "Posts"
         :sitemap-sort-files alphabetically
         :sitemap-function my/org-publish-sitemap
         :sitemap-format-entry my/org-publish-org-sitemap-format
         )
        ("pages"
         :base-directory ,mysite/dir
         :base-extension "org"
         :exclude ,(regexp-opt '("sitemap.inc.org" "posts"))
         :publishing-directory "/tmp/build"
         :htmlize t
         :publishing-function org-html-publish-to-templated-html
         :html-template ,(templated-html-load-template "templates/page.html")
         :recursive t
         :section-numbers nil
         :with-toc nil
         :author ,mysite/name
         :email ,mysite/email
         :auto-sitemap t
         :sitemap-filename "sitemap.inc.org"
         :sitemap-function my/org-publish-sitemap
         :sitemap-format-entry my/org-publish-org-sitemap-format
         )
        ("static"
         :base-directory ,mysite/dir
         :base-extension "ico\\|txt\\|css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg"
         :publishing-directory "/tmp/build"
         :recursive t
         :publishing-function org-publish-attachment
         )
        ("site" :components ("posts" "pages" "static"))
        ))

Clean

(org-publish-remove-all-timestamps)
(org-publish "site" t)