Fix permalinks when id attribute is not present

Fixes the permalinks to `#undefined` caused when the `id` attribute is missing at header elements.