Auto-alias insertion for relative filepaths does not work when creating notes by clicking uninitialized link

Hi all! I’ve been loving this new feature in v1.2.7.

  • Links with folder paths will now automatically insert an alias to the base filename (e.g. [[folder/file]] will expand to [[folder/file|file]])

It’s made it feasible for me to use Relative Path to File links, which has been great for me for portability.

However, aliases aren’t inserted when clicking uninitialized notes. They’re only inserted when typing references to already-created notes.

This means that as I create new notes, I need to go back later and manually insert an alias, otherwise it changes whenever I move notes (and doesn’t render compactly).

Steps to reproduce

  1. Set the New Link Format setting to Relative Path to File.
  2. In an existing note, add a link to a file that doesn’t exist yet (ie [[My New File]]).
  3. Click [[My New File]] to create a new note.
  4. Move the new note to a different folder.

Expected result

  1. When initialized via (3), the reference to [[My New File]] in the existing note should update to [[<path>|My New File]] (note the alias).
  2. When moving the note in (4), the link rendering in Reading View should stay as "My New File" irrespective of where the note moves.

Actual result

  1. When initialized via (3), the reference to [[My New File]] updated to [[<path>/My New File]] (no alias).
  2. Because there was no alias inserted, when moving the note to (4), the link rendered in Reading View changes when the note moves.

Environment

SYSTEM INFO:
	Obsidian version: v1.2.7
	Installer version: v0.15.9
	Operating system: Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:24 PST 2023; root:xnu-8796.101.5~3/DEVELOPMENT_ARM64_T6000 22.4.0
	Login status: logged in
	Catalyst license: none
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

First of all: I strongly recommend to update your installer version (it is 0.15.9 in your case, thus far beyond the current version).

This said obsidian does not (yet) insert an alias if the file you link to is located in the same directory as the note you are linking from. This is default behavior so far, thus no bug.

I am quite certain (couldn’t find it quickly) that there is at least one open feature request for creating a new note in a different folder by clicking an unresolved link that contains a file path (like [[path/to/subfolder/my-new-note]] - I think this is somehow related to your problem.

Edit: even more related is this feature request:

Hey, thanks for taking a look. I’m running this on a few machines, must have forgotten to update my installer on this one.

On this:

obsidian does not (yet) insert an alias if the file you link to is located in the same directory as the note you are linking from.

Totally right, but this is a little different. The new file I’m creating (by clicking a link that doesn’t exist yet) is being created in a new folder. It’s not a problem of being colocated and skipping the alias – it’s that aliases don’t seem to be generated when creating notes by clicking un-created links.

I feel like this rides the line between a bug and a feature request. Maybe it’s working as intended, but it’s definitely unexpected behavior in light of the fantastic alias feature introduced in v1.2.7.

To try to boil this down to something more concrete – what I expect to happen is:

  • When clicking a link that points to a non-existent file,
  • Create that file (as usual),
  • Then in all notes that have links to that now-created file, update them to include an alias.

For example, say you have two notes with a link that doesn’t exist yet.

# Note 1

[[Cool Link]]
# Note 2

[[Cool Link]] 

After I click [[Cool Link]] to generate a new note, I would expect the following result:

# Note 1

[[<path>/Cool Link|Cool Link]]

// (or [[Cool Link|Cool Link]], if the file is in the same directory)
# Note 2

[[<path>/Cool Link|Cool Link]] 

// (or [[Cool Link|Cool Link]], if the file is in the same directory)
# Cool Link

The note I just created

Quick update @alltagsverstand – the feature request you posted isn’t quite what I’m looking for, but your follow-up comment is spot on as to what I’m looking for.

I’m posting this in Bug Reports to start, because the mechanism introduced in v1.2.7 for automatically injecting links leads to unexpected behavior. We’ve been able to drill down into why it happens, but this split where (without deeper investigation) it works sometimes and doesn’t work other times is very strange.

Yeah, but you first create the file in the same folder before moving it to a different folder only afterwards - that’s why I was already thinking a bit further, suggesting the two functions may be a little bit related. Because if you type a link to a non-existing note (like [[my-new-note]]) it is somehow located - though not existing yet - in the same folder. Otherwise, you would write [[path/to/folder/my-new-note]] - but creating a new note in this way is not yet supported by obsidian.

Hope you could follow my reflections - I wrote my first reply this morning before I had my first coffee… :smile:

1 Like

I… think I follow? :smiley:

I’m thinking ahead to how I could write a plugin that manages this, given that it might be quicker to just solve locally, and I’m with you that understanding the note lifecycle is crucial.

Yeah, but you first create the file in the same folder before moving it to a different folder only afterwards

mayyyybe? Under the hood, I don’t think that it’s doing a two-step process. I think it’s actually creating the note in the new location directly. My rationale:

  • Obsidian core settings has the new file location set to Vault by default, not to the same folder.
  • More compelling: If you choose the Absolute path in vault link format, links are auto-updated whenever you move notes around. However, this doesn’t happen on note creation. So whatever hook exists for “Update link when note is moved” isn’t getting triggered on when you create a new note.

Because if you type a link to a non-existing note (like [[my-new-note]] ) it is somehow located - though not existing yet - in the same folder.

Totally see the rationale, but I’m not sure that’s actually what’s happening under the hood?

Same goes back to you. Hopefully you can follow my link of thinking lol.

1 Like

I made a FR out of this

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