Skip to content

Hyperlinks in headers “leak” into header anchors #13405

Closed
@Expurple

Description

@Expurple

Previously reported on the Kayal theme repo, and then on the Hugo forum.

Related to #13401, #13404.


Describe the bug

Header anchors contain the destinations of hyperlinks in the header. This makes them long and unreadable.

This forces me to avoid hyperlinks in headers, which by themselves are functional.

Reproducible example

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

generates

Image

where the anchor at the right is #example-hyperlinkhttpsexamplecom-in-a-header

Expected behavior

I expected a short and pretty anchor, containing only the visible text:

#example-hyperlink-in-a-header

The same as the one generated from a non-hyperlinked version of the same header:

## Example hyperlink in a header

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