emanote icon indicating copy to clipboard operation
emanote copied to clipboard

Relative paths in an folder/index.md file

Open IllustratedMan-code opened this issue 5 months ago • 1 comments

Describe the bug

In an index.md file in a subfolder, normal links relative to the file do not work as if the index.md is in that subfolder, but rather that the index.md is in the parent dir.

To Reproduce Steps to reproduce the behavior:

  1. Create an index.md in a subfolder
  2. Add a relative link in that subfolder
  3. See the broken link
  4. Adjust the relative link as if index.md is in the parent folder
  5. See the working link

See my fork of the emanote template for an example

Expected behavior Relative links should work as if the index.md is where it is.

Comments This is somewhat addressed in the docs:

Instead of foo.md, you can also use foo/index.md (or index.org if using Org Mode ✍️) or foo/index.yaml. Internally, Emanote will treat them as foo.md and foo.yaml respectively.

I would argue that this is a bit confusing though. I'm happy to make a pull request with a more detailed explanation, but how hard would it be to make index.md use the correct relative path? This way editor integration would be better (i.e. path suggestions).

IllustratedMan-code avatar Sep 15 '25 16:09 IllustratedMan-code

I'm happy to make a pull request with a more detailed explanation,

👍🏾

but how hard would it be to make index.md use the correct relative path?

Link resolution is in emanote/src/Emanote/Model/Link/Resolve.hs

But relocateRelUrlUnder is probably relevant for relative links:

https://github.com/srid/emanote/blob/966072803b8bf0456ff94e4e9b6125632d9a0ba1/emanote/src/Emanote/Model/Link/Rel.hs#L101-L107

See also https://github.com/srid/emanote/pull/268

srid avatar Sep 15 '25 17:09 srid