这个更复杂的示例用于发布完整网站,包含转换为 HTML 的 Org 文件、图片文件、Emacs Lisp 源码以及样式表。发布目录为远程路径,且会排除私有文件。
为保证链接正常生效,需注意在 Web 服务器上复刻本地目录结构,并使用相对文件路径。例如,若 Org 文件存放在 ‘~/org/’ ,可发布的图片存放在 ‘~/images/’ ,则图片链接应写作:
file:../images/myimage.png
在 Web 服务器上,图片的相对路径需保持一致。可通过在服务器对应位置创建 ‘images/’ 文件夹并将图片发布至该目录实现。
(setq org-publish-project-alist
`(("orgfiles"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory "/ssh:user@host:~/html/notebook/"
:publishing-function org-html-publish-to-html
:exclude ,(rx (or "PrivateFile.org" (seq line-start "private/"))) ;; regexp
:headline-levels 3
:section-numbers nil
:with-toc nil
:html-head "<link rel=\"stylesheet\"
href=\"../other/mystyle.css\" type=\"text/css\"/>"
:html-preamble t)
("images"
:base-directory "~/images/"
:base-extension "jpg\\|gif\\|png"
:publishing-directory "/ssh:user@host:~/html/images/"
:publishing-function org-publish-attachment)
("other"
:base-directory "~/other/"
:base-extension "css\\|el"
:publishing-directory "/ssh:user@host:~/html/other/"
:publishing-function org-publish-attachment)
("website" :components ("orgfiles" "images" "other"))))