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

Question: How do we configure org-roam/md-roam so that IDs are compatible with Obsidian? #78

Open
offbyone opened this issue Mar 18, 2023 · 7 comments

Comments

@offbyone
Copy link

As it sits right now, it looks like md-roam does a good job of finding articles by title when using the [[wiki-style-links]] but if you open the same file in Obsidian, it tries to create a new top level file without the org-roam ID prefix.

As an example, I have a top level node with ID=20230318085827 and title "PyCascades". My roam template does this:

(add-to-list 'org-roam-capture-templates
             '("m" "Markdown" plain "%?"
               :target (file+head
                        "%<%Y%m%d%H%M%S>-${slug}.md"
                        "---\ntitle: ${title}\nid: %<%Y%m%d%H%M%S>\ncategory: \n---\n%?")
               :unnarrowed t))

So, the file name for this node would be 20230318085827-pycascades.md.

Obsidian, though, expects the node ID not to be in the filename. Is this something I should drop? Is it worth adding a section in the docs for compatibility with solutions like Obsidian? I suspect that what I need to do is to change my file name to ${title}.md alone; is that reasonable?

@nobiot
Copy link
Owner

nobiot commented Mar 25, 2023

I feel it depends on the syntax of wiki link that Obsidian uses. According to this part of its documentation, these two are equivalent:

 - Wikilink: [[Three laws of motion]]
 - Markdown: [Three laws of motion](Three%20laws%20of%20motion.md)

This is different to Markdown-mode and Md-roam.

Md-roam supports [[Title with space]] or [[id]].

So... I think, if you do not wish to override code, your options would be the following:

  1. Have a file name the same as title including the spaces:
    Title: Three laws of motion
    File name: Three modes of motion.md

  2. Have the ID the same as the file name including the spaces:
    ID: Threee laws of motion
    File name: Three modes of motion.md

@nobiot
Copy link
Owner

nobiot commented Mar 25, 2023

Thinking this way, I guess ${title}.md is a reasonable option.

@offbyone
Copy link
Author

My roam-fu is a bit weak; are there any negative consequences to dropping the ID slug from the filename?

@nobiot
Copy link
Owner

nobiot commented Mar 25, 2023

What does “roam-fu” mean?

Org-roam and Md-roam don’t use file names for backlinks and other functions, if that’s what you are concerned with.

@smallstepman
Copy link

What does “roam-fu” mean?

image

@nobiot
Copy link
Owner

nobiot commented May 20, 2023

@smallstepman Thank you. Now I know what it means

@smallstepman
Copy link

using doom:

(use-package! org-roam
  :after org
  :config
  (setq org-roam-directory "/path/to/valut")
  (setq org-roam-dailies-directory "Journal/")
)
(use-package! md-roam
  :after org-roam
  :config
  (set-company-backend! 'markdown-mode 'company-capf) ; add company-capf as company backend in markdown buffers
  (setq org-roam-file-extensions '("org" "md")) ; enable Org-roam for a markdown files
  (md-roam-mode 1) ; md-roam-mode needs to be active before org-roam-db-sync
  (org-roam-db-autosync-mode 1)
  (map! :map doom-leader-map
    "n r o" (λ! (let* ((full-path (buffer-file-name))
                        (pattern "/MY\\.VAULT/\\(.*?\\)\\.md$")
                        (vault-name "MY.VAULT")
                        obsidian-uri match)
                    (when (and full-path (string-match pattern full-path))
                    (setq match (match-string 1 full-path))
                    (setq obsidian-uri (format "obsidian://open?vault=%s&file=%s" vault-name match))
                    (start-process "open-obsidian" nil "open" obsidian-uri)))))
)

SPC n r o will open currently open file in your vault, you need to adjust the name of your valut (obsidian:// url must be registered at OS level, on macOS this happens automatically during installation of obsidian (at least when using brew), for linux search for XDG-OPEN-...somethingsometing)

since obsidian doesnt store id of the files in frontmatter by default, you will also have to add some plugins to obsidian to generate unique ID for all files in your valut, I had success with combinations of these two:

once you do this, all your obsidian files will be available via org-roam-node-find

I did try to also integrate https://github.com/licht1stein/obsidian.el but it was too slow for me (see issue number 39)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants