Markdown links to header id anchor of another file doesn't work under certain conditions
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
GitLab Markdown Guide says:
Using header ID anchors:
- This links to [a section on a different Markdown page, using a "#" and the header ID](index.md#overview)
But that feature doesn't work under certain conditions described below:
- file with link and target file are located in a subfolder.
- link to target file uses absolutely path
(relative to the root folder of project like
[link](subfolder/target_file.md#chapter-1)
) -
file with link doesn't contain
- link to whole target file (like
[link](subfolder/target_file.md)
) - link to chapter of target file with using relative file path (like
[link](./target_file.md#chapter-1)
)
- link to whole target file (like
And that bug will go away as soon as you add into file with link
either link to whole target file like [target file](subfolder/target_file.md)
or link with relative path like [Chapter 1](./target_file.md#chapter-1)
.
Steps to reproduce
All steps has been done in .
- create subfolder
- create target file in the subfolder with chapters
- create another file in the same subfolder
with link to chapter of target file (specified with absolutely path like
[link](subfolder/target_file.md#chapter-1)
) - commit, open file with link and follow the link. In result: 404 page
- edit file with link,
add another link to whole target file like
[target file](subfolder/target_file.md)
, commit, open file with link and follow both of the links. In result: All works correctly
Example Project
What is the current bug behavior?
Link to header id anchor referred to 404 page
because missing -/blob
part in the generated url.
But it happens only until you don't specify other links to the same target file.
What is the expected correct behavior?
Link should refer to specified chapter of target file regardless of other links in the source file to the same target file.
Output of checks
This bug happens on GitLab.com