This blog is written in org-mode, and is exported automatically by org-publish. It's pretty awesome.
I basically just write everything in org-mode, and have a single function to generate the static HMTL for my blog. Feel free to have a look at my configuration.
My work is writing code, so when I blog I tend to include a lot of code blocks in what I write. Syntax highlighting of source code is not just a matter of aestetics, it makes reading source code a lot easier.
To add a source block, simply create a block like this
#+begin_src ruby -n puts "Hello world" #+end_src
This block takes quite a lot of parameters, here are some of the ones I use all the time:
-nAdd line numbers next to your code
+nAdd line numbers, but start the numbering on the next line from the previous code block. Useful when you're explaining code in chunks at a time
:exportsdetermines how to determine what to output, see The
:resultsdetermines what parts of a code block to export, see The
But you know what's really cool? My setup not only prettifies my code samples, it will even run them for me and insert the results of the evaluation.
Code blocks in org-mode can be evaluated when exporting to HTML, and the results of evaluation will be inserted into the exported file.
Inside a code block you set an
:exports parameter to have the
code be evaluated, like this:
#+begin_src ruby :exports both #+end_src
:exports parameter can be one of:
resultsparameter to a code block
You can choose to have the result of code evaluation be the
(implicit return) value
1: "Hello world"
Or you can have the results be what is printed to standard out from
the block, using
1: puts "Hello" 2: puts "Once more"
Hello Once more
You can use customize to tell org-mode which languages it should evaluate. The default is only to evaluate emacs-lisp.
If you set up org-mode to evaluate code blocks, they will be
evaluated when you publish your blog automatically. Use customize
org-confirm-babel-evaluate to a nil value to not have to
confirm the evaluation of every code block on your system. Do
think twice about the implications of this, however, and don't
evaluate code you're uncertain about.
This is not something I'm doing yet, but org-mode lets you export all code blocks from a document into a separate file. This process is called tangling. There's more in the manual.