Skip to content

Instantly share code, notes, and snippets.

@krisfoster
Last active October 10, 2020 16:13
Show Gist options
  • Save krisfoster/11370587 to your computer and use it in GitHub Desktop.
Save krisfoster/11370587 to your computer and use it in GitHub Desktop.
Example set-up for publishing my work notes and todo lists to a site via emacs + org.
;;
;; To run:
;; * eval the buffer
;; * M-x site-publish
;;
(require 'org-publish)
(require 'org-agenda)
;;; Org-mode export settings
;;; Switch of the existing styling for exporting
(setq org-export-html-style-include-scripts nil
org-export-html-style-include-default nil)
;;;
;(setq site-root-dir "<path-to-docs-root>")
;(setq site-root-publish-dir (format "%s/%s" site-root-dir "public_html"))
;(setq debug-on-error t)
;;site-root-dir
;;site-root-publish-dir
;;; Set a custom style for the exported site
(setq org-export-html-style
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/org-manual.css\" />")
;;; Switches off use of time-stamps when publishing. I would prefer to publish
;;; everything every time
(setq org-publish-use-timestamps-flag nil)
;;; Define a publishing project for the site
(setq org-publish-project-alist
'(("org-notes"
:base-directory "<path-to-docs-root>"
:base-extension "org"
:publishing-directory "<path-to-pub-dir>"
:recursive t
:publishing-function org-publish-org-to-html
:exclude "envs.org"
;:auto-sitemap t
;:sitemap-filename "sitemap.org"
;:sitemap-title "Sitemap"
;:sitemap-sort-folders last
:headline-levels 4)
("org-static"
:base-directory "<path-to-docs-root>"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "<path-to-pub-dir>"
:recursive t
:publishing-function org-publish-attachment)
("org-site" :components ("org-notes" "org-static"))))
(defun site-publish ()
(interactive
(let (buff (current-buffer))
;;; Publish the site
(org-publish-project "org-site")
;;; open the agenda view
(org-agenda-list)
;;; Publish the agenda
(org-agenda-write "<path-to-pub-dir>/agenda.html")
(org-agenda-Quit))))
(provide 'site)
;;; site.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment