Publishing notes
I'm trying to re-organize all my notes in a flat structure. I found org-denote to suit my needs. I want to also publish these notes as a static website using minimal dependencies.
We need to install the required dependencies first. I would want to use
straight
as the package manager but in the sprit of keeping dependencies to a
minimum:
(require 'package) (setq package-user-dir (expand-file-name "./.packages")) (setq package-archives '(("melpa" . "https://melpa.org/packages/") ("elpa" . "https://elpa.gnu.org/packages/"))) (package-initialize) (unless package-archive-contents (package-refresh-contents))
htmlize
is used for giving structure to plain text. Here we use it for
syntax-highlighting. haskell-mode
is required for Haskell syntax highlighting.
(package-install 'htmlize)
(package-install 'haskell-mode)
(setq org-html-htmlize-output-type 'css)
I'll use ox-publish
for this use-case.
(require 'ox-publish)
Let's define some vaiables that control what is to be included in the blog and what is to be published.
(setq org-publish-project-alist (list (list "my-org-site" :recursive nil :base-directory (expand-file-name "./") :publishing-directory (expand-file-name "./dist") :publishing-function 'org-html-publish-to-html ;; Don't publish files that have the "draft" tag. :exclude "_draft" :with-author nil :with-creator nil :with-toc nil :section-numbers nil :with-date nil :with-timestamps nil :time-stamp-file nil ;; sitemap will behave like an index page :auto-sitemap t :sitemap-filename "index.org" :sitemap-sort-files 'anti-chronologically :sitemap-title "Index")))
To remove the validation link, we need to set another variable:
(setq org-html-validation-link nil)
Improving the page styling:
(setq org-html-head-include-scripts nil org-html-head-include-default-style nil) (setq org-html-head (concat "<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.css\" />\n" "<link rel=\"stylesheet\" href=\"https://gongzhitaao.org/orgcss/org.css\" />"))
Generate the site output:
(org-publish-all t)
To preview the generated website:
(httpd-serve-directory (expand-file-name "./dist/"))
You can stop the http server once you're done previewing
(httpd-stop)