Publishing Org-mode files to HTML

Emacs is the best editor in the world.

Basics

Create your blog files and css files.

~/blog/org/
   |- css/
   |  `- worg.css
   |- img/
   |- index.org
   `- remember.org

Publishing the org project

(require 'ox-publish)
(setq org-publish-project-alist
      '(;; Publish the posts
        ("blog-notes"
         :base-directory "~/blog/org"
         :base-extension "org"
         :publishing-directory "~/blog/public"
         :recursive t
         :publishing-function org-html-publish-to-html
         :headline-levels 4
         :section-numbers nil
         :with-author nil
         :with-creator nil
         :with-email nil
         :with-timestamps nil
         :auto-preamble t
         ; :auto-postamble nil
         :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/worg.css\"/>"
         :html-head-include-default-style nil
         ; :html-head-include-scripts nil
         ; :html-preamble nil
         ; :html-postamble nil
         :html-link-home "index.html"
         :html-link-up "sitemap.html"
         :html-metadata-timestamp-format "%Y-%m-%d %H:%M"
         :htmlized-source t
         :auto-sitemap t
         :sitemap-filename "sitemap.org"
         :sitemap-title "Sitemap"
         :author "xuchengpeng"
         :email "xucp@outlook.com"
         )

        ;; For static files that should remain untouched
        ("blog-static"
         :base-directory "~/blog/org"
         :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|eot\\|svg\\|woff\\|woff2\\|ttf"
         :publishing-directory "~/blog/public"
         :recursive t
         :publishing-function org-publish-attachment
         )

        ;; Combine the two previous components in a single one
        ("blog" :components ("blog-notes" "blog-static"))))

Then run org-publish-project to generate html files to ~/blog/public folder.


Top