Skip to content

Conversation

@travisbeckham
Copy link
Collaborator

@travisbeckham travisbeckham commented Nov 24, 2025

There are still a few docs with broken reference links that were not fixed in PR #2068

The Problem

Reference links can not be shared between Markdown in a Hugo shortcode and Markdown in the main document. This is because the shortcode is rendered in a different context than the main document. For example, the reference link in the note shortcode will be rendered as plain text:

See: [reference link][1]
 
{{< note >}}

See: [reference link][1]

{{< /note >}}

[1]: https://example.com

Because Hugo renders the shortcode in a different context, the reference could technically be duplicated inside in the shortcode. For example:

See: [reference link][1]
 
{{< note >}}

See: [reference link][1]

[1]: https://example.com

{{< /note >}}

[1]: https://example.com

However, Markdownlint is not aware of Hugo's rendering context and will output the following linting error:

MD053/link-image-reference-definitions: Link and image reference definitions should be needed [Duplicate link or image reference definition: "1"]

The Solution

Unfortunately, Markdownlint will not be able to catch these broken reference links.

With this PR, all reference links inside a shortcode have been replaced with regular links, or with self-contained reference links that use names that are not used in the main document.

Testing

I searched for every note and warning shortcode and verified that the content did not share reference links with the main document.

I searched for "][" in the Hugo public directory, and none of the results were broken reference links.

@travisbeckham travisbeckham requested a review from kflynn November 24, 2025 16:44
Copy link
Member

@kflynn kflynn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it! Thanks for figuring this out. 🙂

@travisbeckham travisbeckham merged commit 2eff71f into main Nov 24, 2025
7 checks passed
@travisbeckham travisbeckham deleted the travis/fixes branch November 24, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants