Wiki: Relative links are rendered as relative to a file and not a directory

Created on 29 Feb 2020  路  6Comments  路  Source: Requarks/wiki

Describe the bug
Note: this is similar but different from issue #1543.

The name of the current page is prepended to a relative mark-down link after rendering (instead of only prepending the current directory).

To Reproduce
Steps to reproduce the behavior:

  1. Go to any markdown page except the home-page (e.g. /test.md)
  2. Create a relative markdown link (e.g. test
  3. Observe that in the preview-pane the link correctly points to /dir/foo.
  4. Render the page and observe that the link now points incorrectly to /test/dir/foo.

Expected behavior
The behavior after rendering should be the same as the preview.

Host Info (please complete the following information):

  • OS: Debian stable
  • Wiki.js version: 2.1.113
  • Database engine: SQLite

Most helpful comment

Note that I just found the "treat relative links as root absolute" configuration option in the "html -> html" pipeline. The description of that option is the following: "For example, a link to foo/bar on page xyz will render as /foo/bar instead of /xyz/foo/bar."

That description seems to imply that the current behaviour would be expected. It still seems to be at odd with any other markdown rendering system, and is also not how wiki.js itself renders the links in preview mode.

@NGPixel can you tell us if the current behaviour is intended or if it's considered a bug?

All 6 comments

Similar to #1201

I can confirm my relative links are rendered absolute links, with name of the current page prepended to them. Relative links are used in preview and allow to navigate between pages in edition mode. Rendered relative links should work the same way.

Confirm on a new installation. All relative links are unusable right now.

This is still happening on 2.2.51: relative links work correctly in preview mode, but they are rendered as if the current file was part of the path (so a link to "foo" inside a file "bar/baz.md" will be rendered to "bar/baz/foo" instead of just "bar/foo").

This is quite a problem as relative links are a very standard feature and rewriting them all to absolute links is not always easy (and makes moving files around in the future more difficult).

Note that I just found the "treat relative links as root absolute" configuration option in the "html -> html" pipeline. The description of that option is the following: "For example, a link to foo/bar on page xyz will render as /foo/bar instead of /xyz/foo/bar."

That description seems to imply that the current behaviour would be expected. It still seems to be at odd with any other markdown rendering system, and is also not how wiki.js itself renders the links in preview mode.

@NGPixel can you tell us if the current behaviour is intended or if it's considered a bug?

This is still here in 2.5.170. Is there any chance to get a comment on whether this issue is considered to be a bug or a feature, even if it can't be fixed now?

This is a very fundamental part of the wiki so it would be great to know what is the behaviour that we can rely on going forward (the one from the preview pane, or the one after rendering)?

Was this page helpful?
0 / 5 - 0 ratings