Nicolas Petton

Web developer, Lisper, Smalltalker & Emacs maniac.

Blogging with org-mode

Blogging with org-mode

October 15, 2013

I just switched my personal website and blog engine from Jekyll to Org-mode. As all my blog posts were already written in the org-mode format, switching was a breeze. Org-mode includes a RSS exporter in the contrib directory and together with its HTML publishing features, it makes it a very powerful website builder.

You might ask why using org-mode at all when I could use wordpress or another blog engine. Well, first, I get to edit my website entirely within Emacs. That alone is a joy. Also, as I already use org-mode for planning, gtd, LaTeX authoring and personal wiki, it just makes sense to use it for my website too.

Here's the bit of elisp that I use for this website:

(require 'org)
(require 'ox-rss)


(defvar nico-website-html-head
"<link href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,400italic' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='css/site.css' type='text/css'/>")

(defvar nico-website-html-blog-head
"<link href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,400italic' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='../css/site.css' type='text/css'/>")

(defvar nico-website-html-preamble 
  "<div class='nav'>
<ul>
<li><a href='/'>Home</a></li>
<li><a href='/blog/index.html'>Blog</a></li>
<li><a href='http://github.com/NicolasPetton'>GitHub</a></li>
<li><a href='http://twitter.com/NicolasPetton'>Twitter</a></li>
<li><a href='/contact.html'>Contact</a></li>
</ul>
</div>")

(defvar nico-website-html-postamble 
  "<div class='footer'>
Copyright 2013 %a (%v HTML).<br>
Last updated %C. <br>
Built with %c.
</div>")


(setq org-publish-project-alist
      `(("org"
         :base-directory "~/org/website/"
         :base-extension "org"
         :publishing-directory "~/Public/nicolas-petton.fr/"
         :publishing-function org-html-publish-to-html
         :section-numbers nil
         :with-toc nil
         :html-head ,nico-website-html-head
         :html-preamble ,nico-website-html-preamble
         :html-postamble ,nico-website-html-postamble)

        ("blog"
         :base-directory "~/org/website/blog"
         :base-extension "org"
         :publishing-directory "~/Public/nicolas-petton.fr/blog/"
         :publishing-function org-html-publish-to-html
         :section-numbers nil
         :with-toc nil
         :html-head ,nico-website-html-blog-head
         :html-head-extra
         "<link rel=\"alternate\" type=\"application/rss+xml\"
                href=\"http://nicolas-petton.fr/blog/blog.xml\"
                title=\"RSS feed\">"
         :html-preamble ,nico-website-html-preamble
         :html-postamble ,nico-website-html-postamble)

        ("images"
         :base-directory "~/org/website/images/"
         :base-extension "jpg\\|gif\\|png"
         :publishing-directory "~/Public/nicolas-petton.fr/images/"
         :publishing-function org-publish-attachment)

        ("js"
         :base-directory "~/org/website/js/"
         :base-extension "js"
         :publishing-directory "~/Public/nicolas-petton.fr/js/"
         :publishing-function org-publish-attachment)

        ("css"
         :base-directory "~/org/website/css/"
         :base-extension "css"
         :publishing-directory "~/Public/nicolas-petton.fr/css/"
         :publishing-function org-publish-attachment)

        ("rss"
         :base-directory "~/org/website/blog"
         :base-extension "org"
         :publishing-directory "~/Public/nicolas-petton.fr/blog"
         :publishing-function (org-rss-publish-to-rss)
         :html-link-home "http://nicolas-petton.fr/"
         :html-link-use-abs-url t)

        ("website" :components ("org" "blog" "images" "js" "css" "rss"))))