Skip to main content

Auto-export Org files to Hugo when modified

Using org-hugo-auto-export-mode

One way to do this is to enable the minor mode org-hugo-auto-export-mode provided by ox-hugo. Maybe you’d have the following in a .dir-locals.el file:

((org-mode . ((eval . (org-hugo-auto-export-mode)))))

Using entr

Another way to do this is to use entr. I have a script export.el that I use to export my Org notes. I can use entr to invoke it whenever a note changes:

while sleep 0.1 do; git ls-files -cdmo --exclude-standard | entr -cdp ./export.el /_; done

The flag -c clears the screen, and -p postpones the first execution until a file is modified. /_ gets replaced with the absolute path of the first file that triggered the event.