# -*- mode: org; -*- #+TITLE: Publish #+SUBTITLE: Publishing this very website. #+AUTHOR: Marius Peter #+DATE: <2022-01-26 Wed> #+OPTIONS: toc:nil #+HTML_HEAD: #+INCLUDE: resources/topnav.org #+TOC: headlines 3 #+begin_abstract In the spirit of [[https://en.wikipedia.org/wiki/Literate_programming][literate programming]] encouraged by Org mode, this entire website's build process is documented on this very page. When Emacs builds this website, it parses and executes the code blocks contained on this page. By mixing behavior with the behavior's documentation, we can future-proof our understanding of the build logic, making it possible to efficiently revisit this website at a later date in order to bring improvements. #+end_abstract * Publishing targets This first section lays out the interactive prompts used to bind export-related symbols with the following publishing targets: - location :: Where should the website be published? - components :: What parts of the website should be built? ** Location Two possible publishing locations are considered: - Local :: The website would be built on the local machine. - Remote :: The website would be built on a remote server, after uploading the selected files via ssh. #+NAME: org-publish-location #+BEGIN_SRC elisp (setq org-publish-location (read-answer "Should the website be built on the local or remote target? " '(("~/tmp-mlnp.fr/" ?l "build website on the local machine") ("/ssh:root@192.162.71.223:/var/www/html/mlnp.fr/" ?r "build website on the remote machine")))) #+END_SRC ** Components #+NAME: org-publish-components #+begin_src elisp (setq org-publish-components (read-answer "Which `org-publish-project-alist' component should be built? " '(("content" ?c "build content (html) website components") ("all" ?a "build all website components")))) #+end_src * Resources This section explores the =.css= and (maybe later) =.js= resources available on the website. ** CSS The main CSS file is located at [[file:resources/css.org]]. * Project components The ~org-publish-project-alist~ variable is used by ~org-publish~ to identify website components and their properties upon export. #+NAME: org-publish-project-alist #+BEGIN_SRC elisp (require 'ox-publish) (setq org-publish-project-alist `(("site" :base-directory "./" :base-extension "org" :publishing-directory ,org-publish-location :recursive nil ; Top-level pages are all in top-level org directory. :publishing-function org-html-publish-to-html :auto-sitemap t :sitemap-filename "resources/topnav-items.org" :sitemap-title "Top-level site links") ("posts" :base-directory "posts/" :base-extension "org" :publishing-directory ,(concat org-publish-location "posts/") :recursive t :publishing-function org-html-publish-to-html) ("styles" :base-directory "resources/" :base-extension "css" :publishing-directory ,(concat org-publish-location "resources/") :publishing-function org-publish-attachment) ("images" :base-directory "images/" :base-extension "jpg\\|gif\\|png\\|svg" :publishing-directory ,(concat org-publish-location "images/") :recursive t :publishing-function org-publish-attachment) ("content" :components ("site" "posts")) ("all" :components ("content" "styles" "images")))) #+END_SRC * Main publishing logic This is the main publishing logic. Execute the following source block to build the entire website. #+NAME: main #+BEGIN_SRC elisp :noweb no-export <> <> <> <> (org-babel-tangle-file "resources/css.org") (org-publish-remove-all-timestamps) (org-publish org-publish-components) #+END_SRC Open the website. [[file:~/tmp-mlnp.fr/index.html]]