先写一个org-to-html 的 lisp 脚本 org-publish.el,如下。
然后解释该块代码,移动到 第一行和最后一行分别执行eval-last-sexp
或者放在 ~/.emacs.d/init.el 最后,每次初始化时执行
(require 'ox-publish)
(setq org-publish-project-alist
`(
;; ... add all the components here)
("org-notes"
:base-directory "e:/org/" ;;放笔记的基目录
:base-extension "org" ;;需要转的文件扩展名
:publishing-directory "e:/public_html" ;;转换的html 存放的路径
:recursive t ;;需要递归转换目录中的org文件
:publishing-function org-html-publish-to-html ;;实际调用的函数
:auto-preamble t ;;
:headline-levels 8
:auto-sitemap t ; Generate sitemap.org automagically...
:sitemap-filename "sitemap.org" ; ... call it sitemap.org (it's the default)...
:sitemap-title "Sitemap" ; ... with title 'Sitemap'.
:html-head ""
:html-link-home "sitemap.html"
:html-link-up "index.html"
:html-inline-images t
)
("org-static"
:base-directory "e:/org/"
:base-extension "css\\|js\\|png\\|jpg\\|git\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "e:/public_html/"
:recursive t
:publishing-function org-publish-attachment
)
("org" :components ("org-notes" "org-static"))
))
- 写org笔记
- org转html
- 推送到github
在目录 e:/org/ 下写*.org 笔记
通过 Alt+x org-publish-project 调用该命令转化成 html 文件
在配置的 e:/public_html 仓库路径中,进行 git add git commit git push 操作
但是,我目前还是直接在html里面写博客,有了xah-lee的 xah-html-mode 脚本,十分方便。
参考
Publishing-optionsorg-publish-html-tutorial