Files
vault/Technical/Emacs/Org Publish.md
Zaine Arch 9645ee23b0
Some checks failed
Build Quartz Notes / build (push) Failing after 21s
update
2026-06-10 20:00:45 +01:00

6.6 KiB

How to insert footnotes:

The Org website[1] now looks a lot better than it used to.

Resources:

https://ogbe.net/blog/blogging_with_org

https://systemcrafters.net/publishing-websites-with-org-mode/building-the-site/

https://orgmode.org/manual/Publishing-options.html

https://www.orgroam.com/manual.html#Configuration

https://www.reddit.com/r/emacs/comments/1j7febh/my_static_website_is_generated_from_org_mode_and/?chainedPosts=t3_116yit2

https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html

https://taingram.org/blog/org-mode-blog.html

https://karthinks.com/software/emacs-window-management-almanac/

https://gongzhitaao.org/orgcss/

https://ogbe.net/blog/emacs_org_static_site

https://edwardtufte.github.io/tufte-css/

https://zilongli.org/code/org-tufte-example

Extra snippets of code:

  ;; Commented out things:

;; (defvar z-head
;;   "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://gongzhitaao.org/orgcss/org.css\" />
;; <link rel=\"stylesheet\" href=\"/style.css\" />")

;; (setq org-html-validation-link nil
;;       org-html-head-include-scripts nil
;;       org-html-head-include-default-style nil
;;       org-html-head z-head)

;; (type-of (car '(rose violet daisy buttercup)))
;; (cadr (assoc "FILETAGS" (org-collect-keywords '("FILETAGS"))))

;; (let ((list '(("post1.org") ("post2.org"))))
;;   (mapconcat (lambda (entry)
;;                (format "- [[file:%s]]" (car entry)))
;;              list
;;              "\n"))


        ;; ("website"
        ;;  :components ("org-main" "org-categories-sitemap" "org-assets" "org-posts" "org-blogs" "org-static"))
;;     :html-head "
;; <link rel=\"stylesheet\" type=\"text/css\" href=\"https://gongzhitaao.org/orgcss/org.css\" />
;; <link rel=\"stylesheet\" href=\"../style.css\" />
;; <script src=\"../script.js\" defer></script>
;; "


(defun z/write-tag-pages ()
"Generate tags/*.org pages listing posts for each tag."
(let* ((site-root (expand-file-name "~/master-folder/org_files/org_web/"))
       (tags-dir  (expand-file-name "tags" site-root)))
  (unless (file-directory-p tags-dir)
    (make-directory tags-dir t))
  (let ((idx (z/gather-tag-index)))
    (maphash
     (lambda (tag items)
       (let* ((slug (z/tag-slug tag))
              (outfile (expand-file-name (format "%s.org" slug) tags-dir)))
         (with-temp-file outfile
           (insert (format "#+TITLE: Tag: %s\n#+OPTIONS: toc:nil num:nil title:nil \n\n* Posts tagged %s\n"
                           tag tag))
           ;; sort newest first if DATE present
           (setq items (sort items (lambda (a b) (string> (nth 2 a) (nth 2 b)))))
           (dolist (it items)
             (let* ((file (nth 0 it))
                    (title (nth 1 it))
                    (rel   (file-relative-name file tags-dir)))
               ;; link to the source .org; org-publish will rewrite to the .html
               (insert (format "- [[file:%s][%s]]\n" rel title)))))))
     idx)
    ;; Also write an index page listing all tag pages 
    ;; (let* ((all ()))
    ;;   (maphash (lambda (tag _items) (push tag all)) (z/gather-tag-index))
    ;;   (with-temp-file (expand-file-name "index.org" (expand-file-name "tags" site-root))
    ;;     (insert "#+TITLE: All Tags\n#+OPTIONS: toc:nil num:nil\n\n* Tags\n")
    ;;     (dolist (tag (sort all #'string-lessp))
    ;;       (insert (format "- [[file:%s.org][%s]]\n" (z/tag-slug tag) tag)))))

    )))


Options stuff:

In Org mode, you can control per-file publishing behavior using special keywords (known as file-local metadata) at the top of the file. These are written like:

```org

```

Here are useful options you can set per file:

Keyword Purpose
——————– —————————————————–
`#+TITLE:` Title of the document
`#+AUTHOR:` Author name
`#+EMAIL:` Email address
`#+DATE:` Date
`#+OPTIONS:` Control export behavior (e.g. toc, num, author, etc.)
`#+HTMLHEAD:` Custom HTML for `<head>` (like styles or scripts)
`#+HTMLHEADEXTRA:` Extra HTML inserted in `<head>`
`#+HTMLPREAMBLE:` Whether to include the preamble (`t`, `nil`, or HTML)
`#+HTMLPOSTAMBLE:` Same but for postamble
`#+LANGUAGE:` Language used for export
`#+DESCRIPTION:` Adds a `<meta name="description">` tag
`#+KEYWORDS:` Adds a `<meta name="keywords">` tag

### Example: Disable TOC and Section Numbers for one file

You can use the `#+OPTIONS:` line like so:

```org

```

This disables the Table of Contents and section numbers just for that file.

Your updated file might look like this:

#+TITLE: Welcome to My Org Website
#+OPTIONS: toc:nil num:nil
#+HTML_HEAD: <link rel="stylesheet" href="style.css">
#+HTML_HEAD: <script src="theme-toggle.js" defer></script>

Here's a reference for some values you can tweak via `#+OPTIONS:`:

Option Meaning Example
————- ——————————– —————-
`toc:` Table of contents (`t` or `nil`) `toc:nil`
`num:` Section numbering `num:nil`
`author:` Show author name `author:nil`
`creator:` Show Emacs/Org creator info `creator:nil`
`date:` Show date `date:nil`
`html-style:` Disable default style `html-style:nil`
  1. The link is: https://orgmode.org