Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative linking should not be broken when you're linking from an index page. #259

Open
jhchabran opened this issue Apr 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jhchabran
Copy link
Contributor

jhchabran commented 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.

  • 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:

docs/a/b/index.mdx
docs/a/b/page1.mdx 
docs/a/b/page2.mdx
docs/a/b/c/index.mdx
docs/a/b/c/page.mdx
  • 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.

@jhchabran jhchabran added the bug Something isn't working label Apr 17, 2024
@jhchabran 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant