Sample org file
1 First heading
Reference to a subheading
2 Second heading
Some stuff written here
2.1 First subheading
Some stuff
2.2 Second subheading
Some other stuff
#+title: Phundrak’s Blog #+author: Lucien “Phundrak” Cartier-Tilet #+hugo_base_dir: ../ #+hugo_section: ./ #+hugo_categories: emacs linux conlanging orgmode * Conlanging :@conlang: ** TODO Writing my conlanging docs with Emacs :emacs:conlanging: * Emacs :@emacs: ** [EN] Automatic Meaningful Custom IDs for Org Headings :emacs:orgmode: :PROPERTIES: :EXPORT_FILE_NAME: better-custom-ids-orgmode :EXPORT_DATE: 2020-06-06 :export_hugo_menu: :menu "main" :END: Spoiler alert, I will just modify a bit of code that already exists, go directly to the bottom if you want the solution, or read the whole post if you are interested in how I got there. #+TOC: headlines 1 local *** The issue About two to three years ago, as I was working on a project that was meant to be published on the internet, I looked for a solution to get fixed anchor links to my various headings when I performed HTML exports. As some of you may know, by default when an Org file is exported to an HTML file, a random ID will be generated for each header, and this ID will be used as their anchor. Here’s a quick example of a simple org file: #+caption: Example org file #+begin_src org :exports code ,#+title: Sample org file ,* First heading Reference to a subheading ,* Second heading Some stuff written here ,** First subheading Some stuff ,** Second subheading Some other stuff #+end_src And this is the result once exported to HTML (with a lot of noise removed from ~
~): #+caption: Output HTML file #+BEGIN_SRC htmlReference to a subheading
Some stuff written here
Some stuff
Some other stuff