Org Mode Project Specification



This page contains the specification to build this website using Org Mode. You might want to look and set some of the variables in the Configuration section.

It can be found here:


To load this configuration, either M-x org-babel-execute-buffer this buffer or put in your Emacs initialization file (.emacs.el):

(setq project-location (expand-file-name "~/Sites/home/website-specification/"))

(if (file-exists-p project-location)
    (org-babel-load-file project-location)
  (message "Warning! project specification (%s) not found (check init.el)" project-location))

Static website functions

We use the functions defined in, which provide facilities for defining a project, previewing it and deploying it:

(org-babel-load-file (expand-file-name "~/Sources/elisp/"))

Project Specification


The project name is:

(setq name "home")

On which port do we run it when previewing locally?

(setq preview-port 4700)

Where are the sources and where do we save resulting HTML files?

(setq sources (expand-file-name "~/Sites/home/"))
(setq local-dest (concat (file-name-as-directory sources) "_site/"))

Where do we deploy the generated HTML?

Set to nil if no remote deployment is necessary, in which case the website will be available in the local-dest directory:

(setq deploy-dest "")

Add the project specification to the list of project managed with av/website functions (which is an association list like org-publish-project-alist.

(website-remove name)
(website-add name preview-port local-dest deploy-dest)

Project Setup

HTML websites projects:

(setq content (concat name "-content"))
(setq assets (concat name "-assets"))

;; this is a custom publishing function to choose the Reveal engine
;; for files ending with -reveal.
;; it replaces org-html-publish-to-html as the ":publishing-function"

(defun av/org-publish-html-or-reveal (plist filename pub-dir)
  "Publish using the standard HTML or Reveal engine, if filename ends with -reveal."
  (if (string-match "-reveal\\.org" filename)
      (org-publish-org-to 'reveal filename ".html" plist pub-dir)
    (org-html-publish-to-html plist filename pub-dir)))

;; this is pure magic to avoid an issue with client-multiplex undefined when publishing with reveal
(setq client-multiplex nil)

(setq project-specification
         :components (,content ,assets))

         :base-directory ,sources
         :publishing-directory ,local-dest
         :publishing-function (av/org-publish-html-or-reveal org-org-publish-to-org)
         :base-extension "org"
         :exclude "\\(.git\\|_site\\|^_.*\\|.*~\\)"
         :recursive t

         :html-doctype "html5"
         :htmlized-source t

         :section-numbers nil
         :with-toc nil
         :with-broken-links nil
         :html-head-include-default-style nil
         :html-head-include-scripts nil
         :html-postamble "
 <div class=\"footer-contacts\">
    <script language=\"javascript\">
      var n = \"adolfo\"
      var s = \"villafiorita\"
      var d = \"\"
      var content = \"<i class=\\\"fi-mail\\\"></i>\"
      document.write('<a href=\"mailto:' + n +'@' + d + '\">' + content + '</a>');

     <a href=\"/adolfo/contacts.html\"><i class=\"fi-mobile\"></i></a>
     <a href=\"/adolfo\"><i class=\"fi-home\"></i></a>
 <div class=\"footer-metadata\">
   <p class=\"author\">Author: %a</p>
   <p class=\"date\">Last modified: %C (created on: %d)</p>
   <p class=\"date\">Published: %T</p>
   <p id=\"source-link\" class=\"source\"></p>

         :base-directory ,sources
         :publishing-directory ,local-dest
         :publishing-function org-publish-attachment
         :base-extension "atom\\|css\\|js\\|gif\\|jpg\\|png\\|svg\\|webm\\|pdf\\|txt\\|xml\\|ttf\\|woff\\|gz\\|vcf"
         :exclude "\\(.git\\|_site\\|^_.*\\|.*~\\)"
         :recursive t


Remove the project specification, if already present, so that we can modify and re-evaluate this page:

(let ( (components (mapcar (lambda (x) (car x)) project-specification)) )
     (lambda (x) (setq org-publish-project-alist (assoc-delete-all x org-publish-project-alist)))

Add the project specification to the list of Org Mode projects:

(setq org-publish-project-alist (append project-specification org-publish-project-alist))