Skip to content

.TableOfContents ignores id's generated by heading render hook #8383

Open
@jmooring

Description

@jmooring

What version of Hugo are you using (hugo version)?

hugo v0.83.0-DEV+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

Without a heading render hook

This markup:

## Section One

Produces this HTML:

<h2 id="section-one">Section One</h2>

With this item in the .TableOfContents:

<li><a href="#section-one">Section One</a></li>

At this point everything is behaving as expected.

With a heading render hook

layouts/_default/_markup/render-heading.html:

<h{{ .Level }} id="{{ printf "%s%s" "foo-" .Anchor | safeURL }}">{{ .Text | safeHTML }}</h{{ .Level }}>

Produces this HTML:

<h2 id="foo-section-one">Section One</h2>

With this item in the .TableOfContents:

<li><a href="#section-one">Section One</a></li>

The item in the .TableOfContents should be:

<li><a href="#foo-section-one">Section One</a></li>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions