Skip to content

Hyperlinks in headers break their ToC entries #13401

@Expurple

Description

@Expurple

I originally reported this to the theme that I'm using. I'm not sure whether the theme or Hugo is responsible for the issue, but the theme maintainer responded that Hugo's built-in ToC generator is at fault.


Describe the bug

By themselves, hyperlinks in headers are functional. But they generate weird ToC entries.

Reproducible example

## Example [hyperlink](https://example.com/) in a header

generates a split-up ToC entry.

The left end takes you to the header (as expected):

Image

The middle part doesn't look like a hyperlink, but it's a separate hyperlink that takes you to an external website:

Image

Finally, the right part doesn't work. It's just nornal text that doesn't take you anywhere:

Image

Expected behavior

Normally, a ToC entry is a one big hyperlink takes you to the header:

Image

This is the most obvious behavior that I can imagine for my reproducer.

Another possible option to keep it "split" but fix the right end (so that it takes you to the header) and underline the middle part (so that it looks like a hyperlink, which it is).

Desktop (please complete the following information):

  • OS: Kubuntu 24.10 (x64)
  • Browser: Firefox 134.0 (64-bit)
  • Hugo Version: 0.129.0 from the distro
  • Kayal Version: 0.3.4

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

$ hugo version
hugo v0.129.0+extended linux/amd64 BuildDate=2024-08-13T17:51:38Z VendorInfo=ubuntu:0.129.0-2

Does this issue reproduce with the latest release?

Yes. Before reporting, I downloaded Hugo 0.143.1 from Github Releases and tried it too.

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