Relative path for Zotero data directory

when I use logseq in one computer with user name is userA, the annotate pdf path is /User/userA/Zotero/…, while I switch to another computer with user name is userB, the pdf path in the note is falied, I think it should use relative path for all attachments…

For example, Computer 1 is Windows , and computer 2 is Mac, they have different Zotero data path.
image

The annotation file (with filename of “hls XXX…” ) created on Mac can not be opened on Windows.

See:image

PS: I noticed that someone also suggested this request.

  1. Zotero pdf annotate for relative path - Giters

This would be very helpful!

Create a unique drive letter that maps to the desired folder on both computer

Example: subst Z: C:\Users\mancub\Dropbox\Zotero and then use the path with the drive letter to load your file

Please explain this in more detail - what does subst achieve? I still see an absolute path, so this would not work across devices if the paths are different, eg because one is a Windows machine (in the office) one is a Mac (in the lab) and one is a linux laptop.

I have created a related feature request here where i point to a successful implementation of this feature in zettlr Link to external pdfs in local Zotero folder and Better BibTex support

subst create a virtual drive that maps to a folder on a physical disk, on Windows. This would not work on macOS or Linux, unless you implement the equivalent workaround for each operating system.

Thanks for the explanation - unfortunately a windows only solution does not work for me. This needs to work cross-platform which is why zettlrs approach, which achieves this sees the most promising: Relative path for Zotero data directory - #4 by menelic

Just want to say that this would also be VERY useful to me. I’d love to store everything that I reference in Zotero and see it within logseq across computers, but without access to relative paths I’m just not sure how its possible on mac.

Same request here! Nice feature if implemented. thanks!

I use windows at Lab and Mac at home, and the PDFs of zotero are located on Zotero’s default storage folder, e.g., \Users\username\Zotero for Mac, and these PDFs in Logseg can be opened correctly, but the pdf annotations are broken because the absolute path is used in file-path of the hls page.
I am looking forward to a solution that does not need to change the storage setting and hope developers resolve it as soon as possible.
Greatly appreciate the work of the developers.

3 Likes

Although it is not directly related to the original request, I would like to suggest a solution for resolving conflicting paths on multiple machines. Logseq offers the option to create multiple Zotero setting profiles, which enables you to use different profiles on various devices to configure the correct pdf path.

1 Like

That just enables you to open files on different machines.
However, the annotations store with absolute file path of the pdf instead of a relative Zotero path of it.
image

subst may help for user with multiple windows machines. However, the virtual disk will be cleaned after rebooting. If you prefer a permanent virtual disk, you should download psubst from github and use psubst.

I second this feature! It is useful not only for Zotero, but in general to store your PDFs out of logseq.

To me, this makes sense when you have a ton of pdfs that are replicated anyway between your machines because you use a cloud drive to store them (eg: Dropbox, OneDrive…) Storing those pdfs out of the logseq graph saves you space when syncinc logseq (specially with mobile, which does not support pdf annotation anyway).

Annotating pdfs out of logseq works if you provide the absolute path to the pdf, for example:

![Title of the pdf](/absolute/path/to/name_of_the_pdf_file.pdf)

but this path is not portable among machines. If you instead change it for a relative path like this:

![Title of the pdf](../../OneDrive/Path/name_of_the_pdf_file.pdf)

then the pdf cannot be open anymore, because logseq insists on prepending assets/ to it, and then complains that the file assets/OneDrive/Path/name_of_the_pdf_file.pdf does not exist.

Why logseq does this? What would be the undesirable side effects of removing that “prepend assets” behaviour? Is there any workaround to “fool” logseq into not to make this url transformation? I tried even this:

![Title of the pdf](file:///../../OneDrive/Path/name_of_the_pdf_file.pdf)

but still logseq is not “fooled” and prepends the assets/ to the path.

1 Like

Hey! I just found a way to “fool” logseq into not prepending the assets/ part, and thus making the relative path to pdf finally work!

Replace each “.” in the path by “%2e” :slight_smile:

![Title of the pdf](%2e%2e/%2e%2e/OneDrive/Path/name_of_the_pdf_file.pdf)
3 Likes

Great hack!

What is Logseq’s reason behind not supporting relative paths?

Is there a security implication?

If so, escaping the dots with %2e will probably be disabled as well.

What about instead of supporting relative paths in Logseq for Zotero, instead allow setting: Zotero linked attachment base directory and Zotero data directory
Then for the links we could use a variable style reference like so: ![Title of the pdf](file:///$zotero/path/in/dir/to/pdf/pdf-file.pdf)
or maybe something like this ![Title of the pdf](zotero:///path/in/dir/to/pdf/pdf-file.pdf)

1 Like

It is not a safety issue, as plugins can circumvent the issue and relative paths are natively supported for audio files.

The problem is related to the architecture of Logseq, see here: issue. Let’s hope this gets implemented, keeps me from using Zotero.

I have the same problem.

1 Like

I have a similar issue, however, for me relative paths would not fix the problem since the paths are very different on different devices (which include my phone!). I would like to be able to set the zotero data directory on a per device basis or something similar, so that I can set a different path for my phone and two laptops each.

1 Like

I solved the problem,and used it for a month, no problem.
Poor English.
Use the plugin GitHub - sawhney17/logseq-citation-manager
The steps are a little complicated.

  1. Use Zotero plugin the better bibtex auto export the xx.bib file, and the bib file path is assets/storages/logseq-citation-manager/xx.bib,

  2. Use Soft link zotfile folder(I use OneDriver sync) to logseq/assets/.
    This step is very important, and we will use this path as the relative path later on

# mac   ln -s
# window    mklink /D

My file path is logseq/assets/zotfile/
And you should make the zotfile/ into .gitignore, not sync, different platform os, different file, Although the same filename.
3. setting for logseq plugin logseq-citation-manager



I use the path assets/zotfile.
My template reference: filename citation_manager_template, in the folder pages\

  alias:: {author lastname} ({date}) {shorttitle}
  tags:: [[Logseq citation manager]],
  type:: {type}
  status:: [[to-read]]
  date:: {date}
  citekey:: {citekey}
  publisher:: {publisher}
  place:: {location}
  extra:: {annotation}
  isbn:: {isbn}
  item-type:: [[book]]
  page-type:: [[book]]
  original-title:: {title}
short-title:: {shorttitle}  
  language:: {langid}
  authors:: {author}
  translator:: {translator}
- *{title}*. {publisher}.
	- {author}, {date}.
- Local library: [{title}](zotero://select/items/@{citekey})
- [[Attachments]]
	- {file++}
- [[Note]]
	-
  1. Use logseq-citation-manager import metadata.


  2. Check it.



    Is relative file path.
    The End.
    中文朋友有问题可以加wx: :face_with_hand_over_mouth:
    zkoo_O

1 Like