You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the content, we are using only absolute links, which is the consequence of a bug with how we handle URLs.
While we can work with it for the time being, it's not good at all for maintenance, and it's very incovenient when writing docs to always have to write absolute links. Relative links are a very basic concept that everyone expects to exist, and it makes it much simpler to move pages around.
If a page is living under docs/a/b/index.mdx the page will be served as https//sourcegraph.com/docs/a/b (note the absence of a final slash).
If a page is living under docs/a/b/page.mdx the page will be served as https://sourcegraph.com/docs/a/b/page
Both are correct, but the problem lies in how we're rendering the links. Assuming we have the following structure:
OK: If within docs/a/b/page1.mdx you write [some link to page2](page2) it will be rendered as https://sourcegraph.com/docs/a/b/page2
BUG: If within docs/a/b/index.mdx you write [some link to page2](page2) it will be rendered as https://sourcegraph.com/docs/a/page2
OK: If within docs/a/b/page1.md you write [some link to c/page2](c/page2) it will be rendered as https://sourcegraph/com/a/b/c/page2
BUG: If within docs/a/b/index.md you write [some link to c/page2](c/page2) it will be rendered as https://sourcegraph/com/a/c/page2
This is happenening because we're removing the trailing slash for cosmetic purposes but we aren't reflecting this behaviour when rendering links, it instead does the classic thing, which is to simply go back to the parent folder. If we had the trailing slash, .i.e https://sourcegraph.com/docs/a/b/ it would have worked.
I understand the reasoning with not having the trailing slash (and it makes sense) and I'm not advocating for changing that. But instead we should ensure that the link rendering code correctly handles this.
The text was updated successfully, but these errors were encountered:
jhchabran
changed the title
Relative linking should not be broken
Relative linking should not be broken when you're linking from an index page.
Apr 17, 2024
In the content, we are using only absolute links, which is the consequence of a bug with how we handle URLs.
While we can work with it for the time being, it's not good at all for maintenance, and it's very incovenient when writing docs to always have to write absolute links. Relative links are a very basic concept that everyone expects to exist, and it makes it much simpler to move pages around.
docs/a/b/index.mdx
the page will be served ashttps//sourcegraph.com/docs/a/b
(note the absence of a final slash).docs/a/b/page.mdx
the page will be served ashttps://sourcegraph.com/docs/a/b/page
Both are correct, but the problem lies in how we're rendering the links. Assuming we have the following structure:
docs/a/b/page1.mdx
you write[some link to page2](page2)
it will be rendered ashttps://sourcegraph.com/docs/a/b/page2
docs/a/b/index.mdx
you write[some link to page2](page2)
it will be rendered ashttps://sourcegraph.com/docs/a/page2
docs/a/b/page1.md
you write[some link to c/page2](c/page2)
it will be rendered ashttps://sourcegraph/com/a/b/c/page2
docs/a/b/index.md
you write[some link to c/page2](c/page2)
it will be rendered ashttps://sourcegraph/com/a/c/page2
This is happenening because we're removing the trailing slash for cosmetic purposes but we aren't reflecting this behaviour when rendering links, it instead does the classic thing, which is to simply go back to the parent folder. If we had the trailing slash, .i.e
https://sourcegraph.com/docs/a/b/
it would have worked.I understand the reasoning with not having the trailing slash (and it makes sense) and I'm not advocating for changing that. But instead we should ensure that the link rendering code correctly handles this.
The text was updated successfully, but these errors were encountered: