Such opposite motivations. I built shite [1] because I want to author everything in org-mode [2], but I don't want publishing hardwired to my Emacs. Also I want HTML templates to be just... HTML (heredocs are rather useful!).
Plus org-babel lets me pull tricks like this:
I want to insert certain HTML fragments in some pages, arbitrarily. There is no sensible way to automate it. BUT, I can source my HTML templates inside any org file, and manually expand it in-line. Like so:
#+BEGIN_SRC bash :results raw html :exports results
source ../bin/templates.sh
shite_template_common_org_inline_sales_banner "."
#+END_SRC
#+RESULTS:
#+begin_export html
<the neatly in-lined HTML>
#+end_export
A potentially simpler solution if you just want something like a header on the page(s), org-publish-project-alist elements support a :html-preamble key that you can assign to any custom function on a per-project basis.
That's how I insert a static <nav> header, and therefore don't have to eval any org-babel blocks as it's just integrated into org-publish. Also the function lives in your init.el this way and not an external script.
Thanks for the tip! I will look into it for other use cases.
In my site maker, however, I explicitly do not want to depend on Emacs for templating or publishing. I have found a works-pretty-well-for-me solution using pandoc's org -> html compiler. It compiles just enough of org's subset for me. Everything else I am happy writing by hand (inline html export blocks written manually).
The case I mentioned above was a bit more annoying, so I used the org-babel trick. Basically, I wanted that little panel in arbitrary places in arbitrary pages. I could have hand-written it, and copy-pasta'd all over the place, but then it would be a chore to change anything (e.g. HTML anchor tweaks etc.). The solution I wrote above still requires manual intervention because pandoc does not execute org babel code blocks. However, my hack solves the important part for me --- viz. not making mistakes while copy-pasting, which in turn lets me easily modify source content and update reference content quickly and correctly.
What to say, it's still using Emacs, but it's an out-of-band composition of tools. Personally, I think of Emacs as not one self-contained all-encompassing thing. But as a part of a workflow solution suited to my tastes and personal idiosyncracies :)
In “Why one.el”, one of the points listed is this:
> I want websites to be written to a single org file,
Since the entire site’s source is in one file, this means individual blog entries (the index.html files) do not by default have their original date after the build and publish, right? For example, if the blog was built and published with one post yesterday and I add one more post today, build and publish, does it mean that both the blog posts on the web server would show up with today’s date/time as when they were modified/updated? If yes, wouldn’t this affect things like browser caching, search engine crawlers, etc.?
That would have to make it to the timestamp on the file system. And whenever a post is modified, that would also have to make it to the file system. Currently this doesn’t seem to be there.
> Have you ever wanted [...]
> "html templates" that are plain Emacs Lisp data,
I can honestly say I've never wanted to write HTML in another language. Html is fine, I'm not sure what the benefit of reimplementing it in other languages is. I see this in python a lot too
1. Write HTML in org-mode. Org-mode is great for thinking.
2. Publish clean HTML.
The other libraries I was seeing were about exporting arbitrary org files for being consumed online. For example, the built-in exporter has a bunch of html classes that include "org" in them.
So I built a custom exporter: https://hg.sr.ht/~zck/ox-zhtml. It's definitely not documented well, but it works well enough for my use.
This is very cool. But has someone done this for Common Lisp? Not that there is anything wrong with the dependency on Emacs but I'd like to avoid that if I can.
Plus org-babel lets me pull tricks like this:
I want to insert certain HTML fragments in some pages, arbitrarily. There is no sensible way to automate it. BUT, I can source my HTML templates inside any org file, and manually expand it in-line. Like so:
That expands to this sales banner https://www.evalapply.org/index.html#standing-invitation (which is also expanded similarly in my hire.org and now.org pages).Nifty!!!
[1] https://github.com/adityaathalye/shite/ is my little hot-reloadin' site maker from shell. I write all of https://evalapply.org with it!
[2] Recently discussed at HN: https://news.ycombinator.com/item?id=43157672 "Why and How I use “Org Mode” for my writing and more (2022)"
reply