💾 Archived View for dctrud.randomroad.net › gemlog › 20200512-org-config.gmi captured on 2020-09-24 at 00:44:41. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
I've seen a few other people doing the #100DaysToOffload who are using Emacs to write. It seems that of among those who are, using ox-hugo is common. It's an exporter from org format into markdown with the front matter that Hugo expects. Hugo is a very nice, fast static site engine but I've taken a different route, and am using a simple elisp configuration calling `org-html-publish-to-html`. This actually publishes all of my site on SDF, so there are three components to the org-publish project named `site`:
(defun spacelite/init-org-publish () ;; Blog publishing (require 'ox-publish) (setq org-publish-project-alist '(("site" :components ("content" "static" "blog"))
The first `content` component takes care of some non-blog pages which live in the root of the site. It's pretty simple with just a few aspects of the default output disabled, and a stylesheet added. That stylesheet is a stripped down and customized version of one from github.
https://github.com/DiegoVicen/org-css
("content" :base-directory "~/Org/www/pages/" :base-extension "org" :publishing-directory "/ssh:dctrud@ma.sdf.org:/meta/www/d/dctrud/" :publishing-function org-html-publish-to-html :recursive t :timestamp t :with-sub-superscript nil :section-numbers: nil :with-headline-numbers nil :style "<link rel=\"stylesheet\" href=\"/static/org-css/stylesheet.css\" type=\"text/css\" />")
The `static` component pushes up any static files I have locally, so they are available to use or link to in pages and posts.
("static" :base-directory "~/Org/www/static/" :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|otf" :publishing-directory "/ssh:dctrud@ma.sdf.org:/meta/www/d/dctrud/static/" :recursive t :publishing-function org-publish-attachment)
Then the `blog` posts component… this is pretty much the same as for the normal pages in the `content` component, but with the addition of a sitemap. This sitemap is just the
simple index page to the posts
. It's automatically written out to an `index.org` file when I call `org-publish-all` and then that goes through `org-html-publish-to-html` to become `index.html` in the `/blog` section of the website.
("blog" :base-directory "~/Org/www/blog/" :base-extension "org" :publishing-directory "/ssh:dctrud@ma.sdf.org:/meta/www/d/dctrud/blog/" :publishing-function org-html-publish-to-html :makeindex nil :auto-sitemap t :sitemap-filename "index.org" :sitemap-title "dctrud@sdf :: Blog" :sitemap-function spacelite/blog-sitemap-function :sitemap-sort-files anti-chronologically :recursive t :timestamp t :with-sub-superscript nil :section-numbers: nil :with-headline-numbers nil ))))
The `sitemap-function` is used to customize the generation of the sitemap `index.org`. It's very simple and ugly, and should probably include header / footer stuff from files rather than just concatenating a bunch of strings, but I'm lazy and it works for now.
A `sitemap-function` has to operate over the `list` that it receives. Here `(org-list-to-org list)` is just creating a normal (bullet) list containing a link to each post, under the `* Recent Posts` top level section.
(defun spacelite/blog-sitemap-function (title list) (concat "#+TITLE: dctrud@sdf :: Blog\n" "#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"/static/org-css/stylesheet.css\" />\n\n" "#+BEGIN_CENTER\n" "[ [[file:../index.org][Home]] | [[file:../cv.org][About Me]] | [[file:index.org][Blog]] | [[file:../selfhosting.org][Self Hosting]] | [[file:../vinyl.org][Vinyl]] ]\n" "#+END_CENTER\n\n" "Welcome to my blog... I'm currently taking part in the [[https://100daystooffload.com/][#100DaysToOffload]] challenge\n" "so there should be something insignificant and uninteresting added here every day :-)\n\n" "Expect a mix of various things... computing, music, bbq, and other topics.\n\n" "* Recent Posts\n" (org-list-to-org list) "\n-----\n"))
And that's all there is to it. Whenever I create a new post (I'm doing a single org file per post) I can call `org-publish-all` and my site will get updated. It's not as fast to publish the site as hugo would be, but it's fast enough for me. At some point I will revisit it to sort out a couple more things that are common:
--------------------------------------------------------------------------------
This post is day 11 of my #100DaysToOffload challenge.
If you want to get involved, you can get more info from