Relative links are broken inside note shortcodes
Summary
Relative links to headings (like this: [some text](#link-here)
) inside templates (such as {{% note %}}
) are broken, and link to the handbook.gitlab.com index page instead.
Steps to reproduce
To reproduce:
- Place a relative link to another heading on a page, inside a
{{% note %}}
template (example from the Markdown Guide page source):
{{% note %}}
For very simple 2 column tables it is better to use [lists](#lists) with strong text in preference
to the complexity of using markdown tables.
{{% /note %}}
- Render the page with Hugo and view it locally in your browser. The link will be broken. In this example, it will point to [https://handbook.gitlab.com/#lists] instead of the intended [https://handbook.gitlab.com/handbook/product/markdown-guide/#lists].
I haven't verified whether the link still breaks when using a template other than {{% note %}}
. I'm new here and I'm not sure which other templates work the same way :)
Example Page
See the tables section of the Markdown Guide
What is the current bug behavior?
The relative link points to the handbook.gitlab.com root, instead of the heading it was meant to point to.
What is the expected correct behavior?
The link should jump to the appropriate heading on the same page.
Relevant logs and/or screenshots
N/A
Possible fixes
- Removing the template around the link does work, but then we lose the effects of the template.
- Changing the link to a full relative path (like
/handbook/product/markdown-guide/#lists
instead of#lists
in the Markdown Guide example also works, but feels a bit strange considering we don't do that elsewhere on that page.