Blog IndexPosts by TagHome

How My org-mode Blog Works

Posted <2015-09-07 Mon 15:16> by Aaron S. Jackson.

Note: This is out of date and I have since replaced all of this with some small shell scripts. You can see them in /scripts if you are interested.

I have decided to quickly document how my blog works. It depends entirely on org-publish and has no dependencies outside of Emacs. The most important part is the org-publish-project-alist definition.

(setq org-publish-project-alist
      '(("blog-posts"
         :base-directory "~/public_html/blog/org/"
         :base-extension "org"
         :publishing-directory "~/public_html/blog/"
         :publishing-function org-html-publish-to-html
         :html-head-include-default-style nil
         :html-head-include-scripts nil
     :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" />"
         :html-postamble "<p><a href=\"./index.html\">Blog Index</a> &bull; <a href=\"../index.html\">Home</a></p>"
     :html-inline-images t
         :with-toc nil
         :headline-numbering nil
         :section-number nil
         :auto-sitemap t
         :sitemap-filename "index.org"
         :sitemap-title "Aaron S. Jackson - Blog"
         :sitemap-sort-files anti-chronologically
         :sitemap-date-format "%e %B %Y %H:%M"
         :sitemap-file-entry-format "%d - %t"
         )))

This creates creates the html for each post, followed by updating the sitemap, which I am actually using as the index page. You can see how the markup has been inserted for the stylesheet and the postamble, which I use for some links.

To create a new post, I have a function which creates a buffer with a proper name, in the right place, and inserts the stuff I need at the top.

(defun asj/new-blog-post (n)
  (interactive "sFilename: ")
  (find-file (concat
          "~/public_html/blog/org/"
          (format-time-string "%Y-%m-%d-" (current-time))
          n ".org"))
  (insert "#+TITLE: \n")
  (insert "#+DATE: ")
  (org-insert-time-stamp (current-time) t)
  (insert "\n")
  (insert "#+FILETAGS: \n")
  (insert "#+INCLUDE: ../incl-after-title.org\n"))

The contents of "incl-after-title.org" just contains the the line below my title. It is in the directory above ./org/ because I don't want it to get compiled into a very empty blog post.

#+BEGIN_HTML
<div class="post-info">
#+END_HTML
Posted {{{date}}} by {{{author}}}.
#+BEGIN_HTML
</div>
#+END_HTML

That's about it. I'd like to work on tagging at some point, which is why I am including the FILETAGS option at the top of each blog post. It works, I like it.

Wanting to leave a comment?

Comments and feedback are welcome by email (aaron@nospam-aaronsplace.co.uk).

Tags: emacs

Blog IndexPosts by TagHome

Copyright 2007-2024 Aaron S. Jackson (compiled: Mon 30 Sep 12:34:20 BST 2024)