kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
867 stars 130 forks source link

Resolving org-roam links when exporting to ox-hugo with multiple folders #668

Closed wn closed 1 year ago

wn commented 1 year ago

Actual Behavior

If my folder structure is of the form

root
  - org
    - reference
      -  apple.org
    - main
      - banana.org

and I reference banana.org in apple.org, the generated markdown will have the format: [banana]({{< relref "../main/banana.md" >}}). However, the generated files will be of the form

root
  - content
    - posts
      - apple.md
      - banana.md

As a result, we get

ERROR 2022/09/03 20:42:33 [en] REF_NOT_FOUND: Ref "../main/banana.md": "/Users/weineng/.org/braindump/content/posts/apples.md:9:26": page not found

Expected Behavior

No errors. Ideally the relref should be "../banana.md" since ox-hugo flattened the tree.

How to Reproduce the Issue

hugo serve

Example Org File

https://github.com/wn/wn.github.io

Generated Markdown File or Error

~/.org/braindump main
❯ hugo serve
Start building sites …
hugo v0.101.0+extended darwin/arm64 BuildDate=unknown
ERROR 2022/09/03 20:56:07 [en] REF_NOT_FOUND: Ref "../main/banana.md": "/Users/weineng/.org/braindump/content/posts/apple.md:8:40": page not found
Error: Error building site: logged 1 error(s)
Built in 12 ms

Ox-Hugo Debug Information

-

kaushalmodi commented 1 year ago

Hello, I might not get to implementing this feature soon. Can you check if the linking works correctly if you do it using the Org ID instead?

wn commented 1 year ago

Hello, how do I change to using org id? Also, could you leave some pointers on how I could implement this feature?

wn commented 1 year ago

For posterity, added a hacky fix for this: https://github.com/wn/wn.github.io/blob/main/shitscript.sh.