Skip to content

TOC incorrect link when Header is a link  #7557

@jhollowe

Description

@jhollowe

When a Heading is a link (## [Heading](https://example.com)), the Table of Contents entry is that link, rather than the link to the section on the current page (so https://example.com instead of this.site/path/to/page#heading).

It seems that the issue is the rendering of the markdown after the TOC has been created. This overwrites the internal link with the header's link. Any other markdown formatting is also applied to the TOC (such as bold, italic, etc). This seems to be the incorrect behavior as the TOC should be consistent and not reliant on the formatting of the headers. However, I believe any emoji or other replacements should still be included in the TOC.

See here for the location of the problem

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

$ hugo version
Hugo Static Site Generator v0.74.3-DA0437B4/extended linux/amd64 BuildDate: 2020-07-23T16:30:30Z

Does this issue reproduce with the latest release?

yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions