New blog

New blog   blog org emacs

[2017-09-12 Tue]

I've decided that I don't like my Wordpress blog (it has adverts, it's hard to edit because I need to use the Wordpress content-management system, I need to write "latex" inside dollar signs to generate LaTeX,…) and I am going to try using Org-mode in Emacs to generate my blog from now on. The current configuration is extremely basic; I will add more functionality later.

To remind me how this works, here is the basic setup of the blog:

  1. I have a directory called web which contains a Lisp script called org-publish.el and has subdirectories:
    • aux, containing auxiliary files like style.css
    • html, containing the html output produced by org
    • org, containing org source files
  2. In particular, web/org contains a file called index.org which is an org file containing summaries of all my posts as top-level headings, each linked to the full article (another org file). This file looks something like the following:
    #+TITLE: Blog
    
    * New blog :blog:org:emacs:
    
    [2017-09-12 Tue]
    
    I've decided that I don't like my old blog and I'm setting up a
    new blog using org-mode.
    
    [[new-blog.org][Read on to find out how]].
    

…and here are the steps used to update the blog:

  1. Open up index.org in Emacs.
  2. Load the file org-publish, by typing
    ALT-x load-file
    web/org-publish.el
    
  3. Edit index.org and the main file for the given blog article by adding a new heading above the others, together with relevant tags and a timestamp (using the command CTRL-c !) and writing the blog entry.
  4. Publish by typing:
    ALT-x org-publish-current-project
    
  5. This generates the HTML files which I can then upload via ftp.

The all-important file in the background is org-publish.el:

(defvar web-head
"<meta name='viewport' content='width=device-width,
initial-scale=1.0'> <meta name='keywords' content='Jonny Evans,
mathematics, geometry, UCL'> <meta name='description'
content='Blog of the UCL-based mathematician Jonny Evans'>
<meta name='author' content='Jonny Evans'> 
<link rel='stylesheet' type='text/css' href='../aux/style.css'/>")

(defvar web-preamble
"<div class='banner'>
<a href='index.html'>Blog index</a> |
<a href='https://www.homepages.ucl.ac.uk/~ucahjde'>Homepage</a></div>")

(defvar web-postamble
"<div class='bottomblock'><a class='cc' href='https://creativecommons.org/licenses/by-sa/4.0/legalcode'>CC-BY-SA</a>, Jonny Evans 2017</div>")

(let ((proj-base (file-name-directory load-file-name)))
  (setq org-publish-project-alist
        `(("website"
           :base-directory ,(concat proj-base "./org/")
           :recursive t
	   :section-numbers nil
	   :with-toc nil
	   :exclude "head.org"
	   :html-head ,web-head
	   :html-postamble ,web-postamble
	   :html-preamble ,web-preamble
	   :base-extension "org"
           :publishing-directory ,(concat proj-base  "./html")
           :publishing-function org-html-publish-to-html))))

The following sites were useful in helping me to figure out what I was doing:

The main features I would like to add to this set-up are:

  • tag-searching (I should be able to create pages associated to different tags just using org-mode, though I may also need to use some background bash scripts if I can't figure out how to do this).
  • tikz figures (doesn't work with MathJax at the moment, but maybe this can be solved within org-mode).
CC-BY-SA, Jonny Evans 2017