-
Notifications
You must be signed in to change notification settings - Fork 970
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
Internal links with ./ should be relative, rather than absolute #686
Comments
So I am kind of on the fence there. I agree that it shouldn't overtake real relative links but adding a protocol feels a bit weird. cc @phil-opp who mentioned that first |
❤️ (as a customer) |
Yeah, I like an Further refinements of the idea: 1a. Is 2a. Should only full content paths be supported, with this Without 2b the difference between 1a and 1b is theoretical only, but even so I much prefer the semantics of 1b over 1a. It’s just crying out for flawless broken link detection, which would feel mildly contrived under 1a semantics. I therefore strongly recommend 1b. Then for 2, there are pros and cons both ways. Relative links are often nice to be able to write (though even without this, you’ll still be able to write relative links, it’ll just have to be as they will appear in the generated HTML rather than as links to the source files), and I think it is a natural thing to expect to be able to write. For involved or large content structures, relative links are a boon indeed. On the other hand, full content paths make for easier global search and replace (you can use naive tools instead of needing clever ones), and the presence of a dedicated operator for the purpose, ideally shoved down people’s throats as the Right Way to Do It, will gently discourage them from writing things in other ways—though some will always grumble about the lack of support for relative paths. I don’t know which way to turn on the point; I lean in one direction, and immediately turn back, yearning for the other. Fortunately I have not been made a pillar of salt. Or for another classical allusion—2b, or not 2b? I… think I’m leaning towards allowing relative links. But at the same time I may have convinced myself not to use them even if they’re supported! (But probably not.) |
It would definitely be 1b, that's currently how internal links are implemented.
💯 I would go with 2a to start with I think. As you say it's much easier to grep: |
It's in the |
Late to the party, but let me add another point to this discussion which was apparently not considered yet: Clickable links in your code editor. When I edit content, I want to be able to add and immediately test links, in my case in VS Code with Alt+Click. I don't even have to save the file and let the site rebuild to find out whether the link is working or not. I still want a link checker to verify everything of course, but a quick feedback on links is really handy. It also lets you navigate the content and edit related pages quicker. With a special syntax like If I understand correctly, then I wished that there was a solution to make If
Using a tag is really cumbersome. What I actually do at the moment is to reference the output file:
It obviously has the drawback of not being clickable… Jekyll wouldn't change .md to .html, but Gitbook does this. I can't recall if they supported a way to refer to the book root, or if everything was based on relative links - I believe there were differences between Markdown files and images, which was rather odd. |
Antora has an interesting approach: https://docs.antora.org/antora/2.2/page/page-id/ |
In #19, internal links were added, but in a syntactically abnormal way: a leading
./
means an absolute URL, relative to the content directory rather than the current file.This is a really bad idea, and a serious design bug: it wreaks havoc with the expected semantics of URLs and relative paths, leading to substantial surprise among users, and breaking tooling that people use. In Vim, for example,
gf
goes to the file under the cursor, and it treats./foo.md
as a relative path, but if the current file iscontent/bar/baz.md
, it looks forcontent/bar/foo.md
rather thancontent/foo.md
.This design decision was briefly questioned in #19 (comment), and the response was this:
Well, you can move the source file around, but not the destination file. If you rename a file, any files that link to it will still need to be updated.
My real counterpoint to this argument is that one of the most common forms of content moving is directory renaming; and going for absolute URLs instead of relative makes that harder, because now all pages inside the section need to have all their links updated, rather than them just working.
Really, it should be parsing the whole thing as a URL, with the content directory being the site root. Thus, things like
https://…
and//…
will be untouched,/foo
will be understood to be relative to the content directory,../foo
to the parent directory (whatever that may be, up to but not exceeding the content directory), and./foo
andfoo
relative to the current directory.Then, let people decide for themselves whether they want to use relative or absolute URL styles—there are advantages and disadvantages to both approaches. In some moods I prefer absolute, because you can search for it in the source more easily; in others I prefer relative, because it’s shorter!
There is always the hazard with this that not all links that start with
/
,./
or other such things are internal links—I might write/foo/
, for example, rather than/foo.md
. If you really want a special prefix, go for a URI scheme, e.g.site:foo.md
; just don’t use./foo.md
, because it’s very confusing.This will be a breaking change. It should be made sooner rather than later, because it will cause pain for users whenever it’s done.
(I’m questioning this now because we’re in the process of moving fastmail.com from a long-in-the-tooth homegrown Markdown.pl system to Zola, and use relative links, with
./
and../
, extensively in our help pages. We’re going to update the links in various ways anyway, but it brought my attention to this design bug.)The text was updated successfully, but these errors were encountered: