Hacker News new | past | comments | ask | show | jobs | submit login
Blogging with Emacs org-mode (sadiqpk.org)
109 points by pksadiq on Aug 8, 2018 | hide | past | favorite | 33 comments

I once tried to do this as well, and got sucked into the rabbit hole of tinkering with little scripts and hacks and trying things out and never writing my first blog post before I lost motivation.

Next time I feel like I want to write a blog I'll just put it on wordpress.com or so.

That’s what I tell everyone. Blogging is about the content, not the form. Do not waste time doing anything else than writing. Setup a wordpress and write, once you have more content take a day to transfer stuff to jekyll or something.

I think the pleasure of doing something like this is in the pure tinkering. Setting up the system just like you want it is kind-of fun. There's some value in that.

If I already considered plain text for writing, I would rather start with a flat file system like Grav[1] or Pico CMS[2] that's based on markdown files, than trying to get the content out of a wordpress db later. Given, WP is at this point the standard to publish online and it's quick and easy.

[1]: https://getgrav.org/ [2]: http://picocms.org/

Depending on the content you are trying to do, different formats help. For me, the few times I get around to writing a blog post, I'm also writing some code to play with. In that, org has been amazingly fun. http://taeric.github.io/Sudoku.html is an example. All of the code and blog material is in one source and I don't have to worry about changing excerpts to put on the page. Literally change the code and rerun.

Markup also matters. With good markup and design the content can be more inviting. I think everyone should learn some basic HTML and CSS. Standard formatting is boring.

Try using Luke Smiths tool 'lb'

I realised a while ago that Github had an org mode renderer. So I've been working on a blog post that's hosted directly on Github (without needing to export to HTML). The renderer has some problems, but it's been OK for my code examples. Completely unfinished blog post here for example purposes only: https://github.com/ygt-mikekchar/oojs/blob/master/oojs.org You can look at raw mode to see what the source code looks like.

One of these days, I'm going to see if I can get something similar working on GitLab (which I've started using and admit to liking better at the moment). I think it should be easy, if a bit expensive (for them) because I should be able to set up a docker image with Emacs and export the HTML to generate a static page.

P.S. Anyone interested in the content of my blog post -- I got stalled trying to reason about the purpose of "this/self", but I've unstuck myself and should be finishing it up soon.

I use org-page (https://github.com/kelvinh/org-page) to write my blog. It has a pretty cool workflow if you are into git, and integrates well with github pages.

The project seems to be dead (or stable!?), but I keep using it because I made some small tweaks to the default theme, which resulted in a clean looking website.

Maybe I'll switch to vanilla org-mode for static website generation in the future since I seem to always be in the mood to remove dependencies from my emacs config these days.

Nikola[0] has an orgmode plugin[1] that works fine for my blog. After I write something up, nikola builds the site (incremental build), I can view it locally to verify the rendering, and finally rsync the changes up to the web server.

[0] https://getnikola.com/

[1] https://plugins.getnikola.com/v8/orgmode/

I use Pelican[0] which also has an org-mode plugin[1]. I tend to use markdown for my blog but I do use org-mode for other organising stuff.

[0] https://blog.getpelican.com/

[1] https://github.com/getpelican/pelican-plugins/tree/master/or...

So the blog index is maintained by hand? https://gitlab.com/sadiq/sadiq.gitlab.io/blob/master/src/blo...

That's a bit of a pickle.

I prefer keeping everything in one file (but exporting to separate files) so I hacked something up[1]. It doesn't build the index, but it would be pretty easy to extend to do so.

There's also Arthur Malabarba's extension[2] to ox-jekyll that's a much more complete solution.

[1] https://gist.github.com/andreareina/37c634f102f819db8e49828f...

[2] http://endlessparentheses.com/how-i-blog-one-year-of-posts-i...

You can do python stuffs too. Similar with jupyter: https://news.ycombinator.com/item?id=16842786

How does jupyter handle embedded data? I've found org mode to be fantastic for opening "literate debugging" of bugs, and being able to do things like embed sql to show the relevant data. My only frustration is that the data get's embedded in the document, I'd prefer it to be a "virtual" element.

With org, either typically you are showing the data, or you reference it elsewhere. You can have a session going that is holding a reference, however, it is much easier and more practical to send it to table or a file. (I almost said "local file" but that isn't necessary, either. It mostly does as you would expect with TRAMP style filenames.)

github.com/gregsexton/ob-ipython is by a good margin my favorite way to do literate programming. All the power of org with most of the Jupyter goodies. Only downside relative to jupyter in browser is missing the interactive javascript widgets, but well worth it for me.

>boring content ahead

aw, it's not boring! Don't sell yourself short!

Did the existing org-to-blog things not work for you? Here's a (probably incomplete) list:

I've been using v1 of o-blog for a while, and it works ok: http://notes.secretsauce.net

Maybe the other options are better, I don't know. Would definitely be interested in hearing people's personal experiences.

> Maybe the other options are better, I don't know. Would definitely be interested in hearing people's personal experiences.

If you are open to trying out Hugo, see if my above comment[1] regarding ox-hugo.

[1]: https://news.ycombinator.com/item?id=17721272

I ran into a problem following the example

``` $ emacs --batch -q -l src/my-web.el -f org-publish-all Cannot open load file: No such file or directory, htmlize ```

I tried and succeeded in installing htmlize. But still ran into this issue. How do I resolve this?

If you are trying to use htmlize, download the file[0] to src directory, such that htmlize package is available as ~/web/src/htmlize.el

Now run emacs:

  ~/web$ emacs --batch -q -l src/htmlize.el\
  -l src/my-web.el -f org-publish-all
See https://gitlab.com/sadiq/sadiq.gitlab.io/blob/master/.gitlab...

You can simply download/clone the complete repo[1] and run the above command from its root directory.

[0] https://github.com/hniksic/emacs-htmlize/blob/master/htmlize...

[1] https://gitlab.com/sadiq/sadiq.gitlab.io

> My idea was to put all articles (posts) in a single org file

Unfortunately, this is exactly what I'd like to do. Does anyone have cool examples of this alternate workflow?

I created the not-so-imaginativel-named org-blog (https://github.com/ctindall/org-blog), which is not a static generator -- it's a Python daemon that builds pages on the fly -- but it allows you to put all your posts in a single file.

I think it is this[1], right? I think you should update the Worg: Org Blog Wiki[2] with it if you want more people to discover/use it.

I liked the thoroughness of "why I made this project" in its README.

[1]: https://github.com/ctindall/org-blog

[2]: https://orgmode.org/worg/org-blog-wiki.html

I developed the ox-hugo[1] Emacs package, which allows exporting multiple posts (even the website structural pages like Home page, About page, etc.) from a single Org file.

So here's the elevator pitch:

- ox-hugo is an Emacs package that exports from Org mode to Markdown format that's compatible with Hugo (https://gohugo.io) / Blackfriday + automagically converts natural* Org metadata to TOML/YAML front-matter.

- To understand what I mean by "natural" Org metadata, see this table[2].

- ox-hugo works with Hugo. I let each tool to do what they are best at:

(i) Org mode deals with the rich markup (Org macros, INCLUDE, TOC, keywords, Org Babel, NoWeb, property/tag inheritance, etc.) and Emacs/Elisp processing, and

(ii) Hugo deals with all the "Web stuff" in super-fast fashion (roughly 500 pages in less than a second [depends on your theme efficiency too]): Markdown->HTML conversion, generation of list pages, taxonomy pages, RSS/Atom/JF2/.. feeds, minification, cache busting, page generation using JSON/TOML/.. data, etc.

- I prefer having most of the posts be exported from a single Org file (my blog[6] source[3]). So ox-hugo definitely supports that. It also supports the conventional flow of exporting each Org file to a single post too (I use that style too, for my "notes" posts).

- The ox-hugo doc site[1] is dog-fooded by ox-hugo itself. Here's the single Org file[4] that holds the content for the entire site.

--> Here are few Real World Examples[5] of people using ox-hugo + Hugo.

== Refs ==

[1]: https://ox-hugo.scripter.co/

[2]: https://ox-hugo.scripter.co/doc/org-meta-data-to-hugo-front-...

[3]: https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/blob/ma...

[4]: https://raw.githubusercontent.com/kaushalmodi/ox-hugo/master...

[5]: https://ox-hugo.scripter.co/doc/examples/

[6]: https://scripter.co/

PS: Your user name sounds a bit familiar. So I apologize if I have already mentioned ox-hugo to you.

I really enjoy using ox-hugo to blog as well, it works very well and does everything that I need it to do! @kaushalmodi did a great job developing it

Thank you for the write up and for the tool. I’ll be checking this out.

I can’t remember anyone mentioning ox-hugo to me before, but that may be more an indictment of my memory :-)

+1 , really nice integration. I use it daily for my blog. Kudos to you. (:

Nikola, linked above, has a very nice org plugin.

Yes. o-blog.

Looks like the author has abandoned it, the last activity was in, and the issues say it doesn't work on Emacs 25.

Looks interesting though.

I do something similar for my blog. I love orgs embedded code features

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact