Emacsist RSS --- If never, make it ever: C-h C-h

Org-babel-tangle building a hugo blog


这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

There are examples of doing this already, namely here and here but neither is to my taste in engaging with emacs and org-mode. Namely, there is a charm to just write in markdown after dumping a template to the org-file used for my blog setup and posts.

Why? The whole blog is the one org file. One run of (c25l-hugo-setup) builds every file that a blank blog would need (provided you tangle out your config.toml, whatever templates, and whatever else you need.) After that, just running (org-babel-tangle) again will refresh everything to the newest changes as reflected in this single source file.

(defun c25l-hugo-post (title)
  (interactive "sTitle: ")
  (org-insert-heading) (insert title)
  (insert (concat "\n"
   "#+begin_src html :tangle /tmp/blog/content/post/" (replace-regexp-in-string " " "_" title) ".md\n"
   "categories = []\n"
   "title = \"" title "\"\n"
   "date = \"" (format-time-string "%Y-%m-%dT%H:%M:%S" (org-current-time)) "-05:00\"\n"

(defun c25l-hugo-setup ()
  ;;run me in the org file for your blog!
  (shell-command "rm -rf /tmp/blog; mkdir -p /tmp/blog/content/post /tmp/blog/themes /tmp/blog/layouts/partials/ /tmp/blog/static/")
  (shell-command "git clone **whatever you like**/tmp/blog/themes/theme")
原文出处: cpb83
原文地址: http://cpb83.github.io/post/Org-babel-tangle_building_a_hugo_blog/
原文时间: 2016-04-22 10:04
本文地址: http://emacsist.com/10859
整理时间: 2016-04-24 23:13

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .