relative md links not working when in subdirectories
See original GitHub issueIf I have the following md directory structure:
/var/www/html/docs/ /var/www/html/docs/index.html /var/www/html/docs/test/ /var/www/html/docs/test/top.md /var/www/html/docs/test/subdir/ /var/www/html/docs/test/subdir/subdir.md
With index.html contains:
<zero-md src="test/top.md"></zero-md>
And top.md contains:
[subdir](subdir/subdir.md)
Then when browsing to “http://<domain.com>/docs/” the “subdir” link in the zero-md rendered html of top.md incorrectly points to: http://<domain.com>/docs/subdir/subdir.md
whereas the “subdir” link should point to: http://<domain.com>/docs/test/subdir/subdir.md so there is a missing path sub dir of “test”
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
GitHub relative link in Markdown file - Stack Overflow
If i was linking from a .md in one subdir to another, i think it would handle relative link just fine. Problem occurs...
Read more >relative links in markdown to the current directory or via subdir ...
The relative link is translated incorrectly to the root of the project instead of the current directory. Relative links to the current directory ......
Read more >Configuration - MkDocs
An external link may be a full URL or a relative URL. Any path which is not found in the files is assumed...
Read more >Relative urls in readme.md files only work half the time. (BB ...
I've confirmed that the problem with relative links only works if the readme is rendered at a specific commit. If it is rendered...
Read more >Reference - mkdocs-literate-nav - GitHub Pages
Links in the nav file directly under the root docs dir are relative to the docs dir, and for nav files that are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Better handling of relative links is definitely in the pipeline. This is especially true for the use case @fbalady-synamedia described:
However, in the case of intercepting anchor links to another
.md
file (within the same domain), and doing a re-render, this falls within the realms of client-side routing and SPA, so I’m not sure if it’s something people would expect.Instead, a gist (or a recipe) like what @neskk posted would work quite well outside the remit of
zero-md
- where you can optionally chain History APIpushState
to update the URL bar if your use-case requires it.IMO, what
zero-md
needs is a more elegant (and more up-to-date) way that exposes hooks where consumers can subscribe to and extend functionality, customised to their needs, if required. This also goes to my Long List of Stuff to Change in the new release. 😅Thanks for the feedback @fbalady-synamedia - since
zero-md
is due for an update I’ll probably add logic for relative link handling in the next release soon. Let’s keep this issue open for now - stay tuned!