Even with "shortest path when possible" in link-format-setting and unique filename path OB insertes full path in links - sometimes

After updating to 1.7.0 I noticed, that new file links sometimes where automatically inserted in long form instead of in shortest path despite

  • setting is still “shortest path when possible” and
  • no other note with a similar name exists somewhere in the vault

What am I doing?
As always typing the two brackets [[ and in case of an already existing note choosing the existing note from the popup. And sometimes (!) but not always it suddenly uses the full path. At other instances it doesn’t do this. Even with one and the same note being selected.

Much worse is, what I noticed later: OB changed the links in some notes to the full path where it never ever was full path before. (I never use the full path thing.)
In this process it even destroyed whole blocks of text/headers that contained links into a complete mess consisting out of wildly scattered fragments of the links and the sourrounding text in some notes.

As it is a behavior I can’t tell you when it occurs and I could’t provoke it by purpose I can’t provide you with further ideas. There is one plugin I hold as a suspect to be accountable for that whole thing - graph banner. A plugin I really appreciate very much, because it is very useful. So I opened a bug report there, too.

What it made suspicious to me was, that it showed a single note twice in the graph banner, which wasn’t the case, when turning off the plugin and confirming the local graph shows the note only once with the Obsidian-own plugin.

Because I only notice it after opening a note I can’t tell you, if this happened all in one instance and I discover the mess bit by bit or if it happenes in the background…

And, yes, I use a ton of plugins, and no, I couldn’t reproduce it in a vault without plugins.

If you can’t reproduce it without plugins, this is likely a plugin problem. Follow the troubleshooting instructions here:

i tried that

…does that* and more…

might want to check it out

* well…you can add the graph below your YAML with a hotkey bound to a templater script:

<%*
//Force (switch to) live preview for the graph to be seen
const view = app.workspace.activeLeaf.getViewState()
view.state.mode = 'source'
view.state.source = false
app.workspace.activeLeaf.setViewState(view)

const separator = '---';
const currentFile = app.workspace.getActiveFile();
if (!currentFile) return;
const editor = app.workspace.activeEditor.editor;

const fileContent = await app.vault.read(currentFile);
const firstSeparatorPos = fileContent.indexOf(separator);
const secondSeparatorPos = fileContent.indexOf(separator, firstSeparatorPos + 1);

if (secondSeparatorPos !== -1) {
  const dynamicContent = `\n\n%%\n\`\`\`templify-embed\n{"state":{"uniqueID":"hth23"},"type":"localgraph"}\n\`\`\`\n%%`;

  const contentToAdd = dynamicContent.replace('${currentFile}', currentFile);

  const updatedContent = fileContent.slice(0, secondSeparatorPos + separator.length) +
    contentToAdd +
    fileContent.slice(secondSeparatorPos + separator.length);

  await app.vault.modify(currentFile, updatedContent);
editor.setCursor({ line: 0, ch: 0 });
}
_%>

another hotkey can be used to tied to another script that removes the graph, or you can leave it there…

Thank you for this snippet… have to try it out! :smiley:

Apart from where the full-path-links came from in the vault: is there a solution, how I can make them all disappear at once?

Anything that could revert all that long links to their shortest possible form (of course only if there isn’t a duplicate name for some note in some folder within the vault).

that’s an outside of obsidian replacement job detail…
i wouldn’t worry too much about it, but you’d need to add an alias to those links to make them better blend in in the texts…

happened to me before when I created a filename that was already present in a different folder: where I didn’t have an alias in those links, the texts were messed with the newly created path prefix

i had github desktop open and reverted the changes…

  • only if there are hundreds of cases need to be dealt with…

otherwise if it involves only a dozen or so backlinks, you can search in the search modal, click on results one by one and remove the foldername/ parts…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.