# Disable auto id generation in org-mode html export

How can I disable inclusion of ids when exporting file as html

Say for example, in the following file I have disabled toc

#+TITLE: Using org-mode
#+HTML_DOCTYPE: html5
#+OPTIONS: toc:nil html-style:nil html-scripts:nil

* Where to start
** Let’s begin here


Now if I export it with M-x org-html-export-to-html, I get the following output:

...
<div id="outline-container-org0c7ecf1" class="outline-2">
<h2 id="org0c7ecf1"><span class="section-number-2">1</span> Where to start</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-orga4a6d26" class="outline-3">
<h3 id="orga4a6d26"><span class="section-number-3">1.1</span> Let’s begin here</h3>
</div>
</div>
...


I would like to not add the id attribute at all unless a CUSTOM_ID property is set or toc is enabled.

These randomly generated ids break when regenerated and thus make it less useful as an id that can be linked from some other source.

As a side note, this results in unnecessary noise in commits (that's the primary reason I'm trying to avoid this).

• I have the same problem here, then I dive into the org source code, the id is generated by org-export-new-reference and returned by org-export-get-reference, the latter function gets called many places in ox-html.el, and unfortunately, there is no even an option to change the behavior, so, it's quite hard to achieve this, what a tragedy... – Kelvin Hu May 30 '18 at 3:58
• This is Emacs, you could just advise the function ( emacswiki.org/emacs/AdvisingFunctions ), or even redefine it. – Charl Botha Sep 9 '18 at 9:36

As others have said, it seems there is no out-of-the-box solution to this problem. Here is a hacky solution that uses an output filter and a regex to remove the id attributes from the final HTML output:

(defun html-body-id-filter (output backend info)
"Remove random ID attributes generated by Org."
(when (eq backend 'html)
(replace-regexp-in-string
" id=\"[[:alpha:]-]*org[[:alnum:]]\\{7\\}\""
""
output t)))