Files
org_roam/20250806155335-emacs_stuff_org_publish.org
2025-12-28 20:41:18 +00:00

6.1 KiB
Executable File

emacs-stuff-org-publish

How to insert footnotes:

The Org website1 now looks a lot better than it used to.

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.)
`#+HTML_HEAD:` Custom HTML for `<head>` (like styles or scripts)
`#+HTML_HEAD_EXTRA:` Extra HTML inserted in `<head>`
`#+HTML_PREAMBLE:` Whether to include the preamble (`t`, `nil`, or HTML)
`#+HTML_POSTAMBLE:` 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