Title: My blog workflow
Author: Solène
Date: 03 January 2021
Tags: life blog
Description: 

I often have questions about how I write my articles, which format I
use and how I publish on various medias. This article is the
opportunity to highlight all the process.

So, I use my own static generator cl-yag which supports generating
indexes for whole article lists but also for every tags in html,
gophermap format and gemini gemtext. After the generation of indexes,
for html every article will be converted into html by running a
"converter" command. For gopher and gemini the original text is picked
up, some metadata are added at the top of the file and that's all.
Publishing for all the three formats is complicated and sacrifices must
be made if I want to avoid extra work (like writing a version for
each). For gopher, I chose to distribute them as simple text file but
it can be markdown, org-mode, mandoc or other formats, you can't know.
For gemini, it will distribute gemtext format and for http it will be
html.
Recently, I decided to switch to gemtext format instead of markdown as
the main format for writing new texts, it has a bit less features than
markdown, but markdown has some many implementations than the result
can differ greatly from one renderer to another.

When I run the generator, all the indexes are regenerated, and
destination file modification time are compared to the original file
modification time, if the destination file (the gopher/html/gemini file
that is published) is newer than the original file, no need to rewrite
it, this saves a lot of time. After generation, the Makefile running
the program will then run rsync to various servers to publish the new
directories. One server has gopher and html, another server only gemini
and another server has only gopher as a backup.
I added a Mastodon announcement calling a local script to publish links
to new publications on Mastodon, this wasn't merged into cl-yag git
repository because it's too custom code depending on local programs. I
think a blog generator is as personal as the blog itself, I decided to
publish its code at first but I am not sure it makes much sense because
nobody may have the same mindset as mine to appropriate this tool, but
at least it's available if someone wants to use it.

My blog software can support mixing input format so I am not tied to a
specific format for all its life.

Here are the various commands used to convert a file from its original
format to html. One can see that converting from org-mode to html in
command line isn't an easy task. As my blog software is written in
Common LISP, the configuration file is also a valid common lisp file,
so I can write some code in it if required.

```Common-lisp code defining various commands to convert files into html
(converter :name :gemini    :extension ".gmi" :command "gmi2html/gmi2html data/%IN | tee %OUT")
(converter :name :markdown  :extension ".md"  :command "peg-markdown -t html -o %OUT data/%IN")
(converter :name :markdown2 :extension ".md"  :command "multimarkdown -t html -o %OUT data/%IN")
(converter :name :mmd       :extension ".mmd" :command "cat data/%IN | awk -f mmd | tee %OUT")
(converter :name :mandoc    :extension ".man"
           :command "cat data/%IN  | mandoc -T markdown | sed -e '1,2d' -e '$d' | multimarkdown -t html -o %OUT")
(converter :name :org-mode  :extension ".org"
           :command (concatenate 'string
                                 "emacs data/%IN --batch --eval '(with-temp-buffer (org-mode) "
                                 "(insert-file \"%IN\") (org-html-export-as-html nil nil nil t)"
                                 "(princ (buffer-string)))' --kill | tee %OUT"))
```

When I define a new article to generate from a main file holding the
metadata, I can specify the converter if it's not the default one
configured.

```Common-lisp code generating an article from its metadata
;; using default converter
(post :title "Minimalistic markdown subset to html converter using awk"
      :id "minimal-markdown" :tag "unix awk" :date "20190826")

;; using mmd converter, a simple markdown to html converter written in awk
(post :title "Life with an offline laptop"
      :id "offline-laptop" :tag "openbsd life disconnected" :date "20190823" :converter :mmd)
```

Some statistics about the various format used in my blog.

* markdown :: 183
* gemini :: 12
* mandoc :: 4
* mmd :: 2
* org-mode :: 1