4 ms·
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
by adityaathalye 2y ago
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
That expands to this sales banner https://www.evalapply.org/index.html#standing-invitation 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/ https://github.com/adityaathalye/shite/ is my little hot-reloadin' site maker from shell. I write all of https://evalapply.org https://evalapply.org with it!
[2] Recently discussed at HN: https://news.ycombinator.com/item?id=43157672 https://news.ycombinator.com/item?id=43157672 "Why and How I use “Org Mode” for my writing and more (2022)"
- bm3719 2y agoA 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.
- adityaathalye 2y agoThanks 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 :)