First by blog, I mean a collection of articles, which contain text, images, links etc. Nothing fancy.
What am I doing with my ghost blog? Haha...
Set up projects to publish files
Given an org file, one can use
org-export-dispatch to convert it to various formats, such as html, LaTeX, plain text... If you have a directory-worth of org files to convert, you can define a project in
org-publish-project-alist, in which you can set up various parameters to your hearts desire and then use
org-publish-project to export everything in the directory to the publishing directory specified as one of the project parameters. It even has caching so that it won't convert unnecessarily your org files. Conversion happens only when the files are updated, well, unless you force it to disregard the cache.
To copy images, css files, js files etc. as-is to the publishing directory, you set up another project. Each project uses one method to export files.
It's cumbersome to have to run two projects when exporting. Thus you set up an empty project and declare that it depends on the two projects you just defined. Then you just need to run this empty project to export everything. At this point, you can just forget about the previous two projects.
I followed https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html which, I have to remark, doesn't have a clear view of who the readers are. Sometimes it thinks the readers are ignorant and sometimes it assumes the readers know all.
It's really nice!
As org files can embed arbitrary code, it is so much more convenient than making html files by hand. If you blog about code, with the help of htmlize, syntax highlighting is trivial.
You can include arbitrary html in
<head> by defining the variable
org-html-head. This variable can also be set in each org file using
#+HTML_HEAD:. This can be used multiple times to accommodate line breaks. I supply a
:preparation-function to set this variable. It reads from my template file and set the variable to the content. In particular, you can supply your own CSS style files in this way, if you already have a site and want to match style.
You can also include arbitrary html in
<body> by using the
#+begin_export html block
#+begin_export html whatever html... maybe include some embed code copied from gist... <script src="someEmbedCode.js"></script> #+end_export
I think having any preprocessor to html is great. It can include a common header. Updating it only requires re-publishing all files. For html files that I already have, I can easily make them org files by using
#+begin_export html block. I can just include the body part, which is the content, as is and throw out the outdated header. No need to put in extra effort to convert to pure org.
Musing on index file
I guess if I want, I can set up a
:completion-function to go through the list of org files in the directory, extract the title variables and make an index.html that links to all files.
You don't need any external tool to publish a simple blog. Just use org-mode to export things.