Website Generation From Org

article

This is out of date. I’m now using a vibecoded base to create my website.

Description of tools

  • ox-hugo is an emacs package which exports individual .org files into hugo-style .md files.
  • Hugo is a static site generator which uses .md sources to create a static site.

Workflow

Site generation is not finished yet, so this is subject to extreme change. The basic workflow is likely fixed however.

  1. Use emacs and org to write notes.
  2. Use org-hugo-export-to-md to export (a single note) to hugo-like markdown.
  3. Put that markdown in the content folder of a hugo site.
  4. Run hugo server --buildDrafts --navigateToChanged to generate site.

ToDo

  • Write scripts in emacs to fascilitate multiple org -> md exports at once, in particular, add the ability to automatically export linked org files.
  • Add a tag/property publish in org files which flags whether a given org file should be published or not. Only publish those which are publishable. If a published file links to an unpublished file, link to 404 or to a “this page is not yet published (or may never be published)” page.
  • Update the theme of the Hugo site to be nicer.

Known issues and fixes

  • calls to org-hugo-export-as-md initially threw an error: “invalid function: org-export-with-buffer-copy”. This is because in the branch of org I use, needed for better org-latex-preview functionality, the function org-html-format-latex includes a call to the deprecated org-export-with-buffer-copy function. This is now a macro, defined at runtime, not a builtin function. The fix includes overriding the org-html-format-latex call, and is handled in the doom.org source config file in the “Website” section. The fix is copy and pasted from this github thread.
  • in the current test instantiation of the site (~/Desktop/websites/hugo-site/), math-jax does not automatically work, it must be switched on. To do this, one follows the instructions here in the Hugo docs. However, I spent a while troubleshooting before I realized that the two files one creates, the partial template /layouts/_partial/math.html and /layouts/baseof.html must be place in the theme layout folder not the site layout folder. That is, the paths ought to be /<base-site-dir>/themes/my-theme/layouts/_partial/math.html and /<base-site-dir>/themes/my-theme/_defaults/baseof.html respectively. The directory /<base-site-dir>/layouts/ seems to be empty, I don’t think anything should go in here.