Add option to always preserve original link text as display text (alias) when the target note is renamed (don't change original text when updating links)

I noticed that when I’m writing notes for some terms I just create links for the future notes and leave them as is in the text. Now when I get back to creating actual notes for those links I usually like to rename the notes and this also changes the link in the original note which is nice, but it would be nicer if it preserves the original link as a display text.

Example:

Vitamin C is required for the biosynthesis of [[collagen]].

In this example collagen is a totally new link which doesn’t have it’s actual note. Now when I finally have time to go and create the collagen note, I usually like to fix the name and do renaming. So if I rename the note to Collagen the original note will get updated to:

Vitamin C is required for the biosynthesis of [[Collagen]].

This is nice and good, but ideally I would like it to preserve the original as a display text for the link like this:

Vitamin C is required for the biosynthesis of [[Collagen|collagen]]

This way I could go crazy with renaming notes and wouldn’t need to be concerned with the lost meaning in the text which links to the note.

I know that I could write it like [[collagen|collagen]] in the first place, but it’s annoying and time consuming to write the same word twice.

From the programing perspective it shouldn’t be hard to implement this. During renaming you would only need to check if the link already has a display text and if not, keep the original as a display text and rename the link.

11 Likes

Why simply not to write “… collagen (see, [[collagen]])”? This way your text is preserved and the link can be renamed Without breaking anything. And this way developers can spend their time on more urgent items :slight_smile:

1 Like

I think this is a popular feature request. Is this similar to your request?

3 Likes

Aliasing would work, but it’s way harder to implement it. All I’m asking is to keep original note name as a display text after renaming if the link didn’t have a display text before.

With aliasing you would need a way to keep all those aliases somewhere in the note. Maybe you would need to introduce some meta configuration for notes where you could keep all the aliases, but as I see it, it’s a functionality which would need a lot of thinking and work to implement it correctly.

2 Likes

Just wanted to open a feature request for this and discovered this older request.

I would like to push this request by showing a use case similar to the one described by @TheHeadline - a use case I am actually confronted with several times a day:

Use case or problem

Let’s say I have to folders in my vault:

  1. “literature” - where I store my literature notes and excerpts
  2. “notes” - where I store my personal atomic notes

The following use case is a quite typical one:

I am working on a literature note (I might have created it from zotero with mdnotes, for example, showing my highlights as quotations) and within this note there is the following quotation:

obsidian is an amazing software you can for example use to build your personal zettelkasten (Source, p. 2)

When I now review my literature note, I want to create a personal note about “zettelkasten”. Thus, I double click the term and put it in brackets: [[zettelkasten]]. When I now click on this link, obsidian will create a new note named “zettelkasten” and jump to it directly. I write some stuff in there and move the note to my “notes” folder. Obsidian updates the link automatically (which is really cool!), in the original literature note the quotation now reads like:

obsidian is an amazing software you can for example use to build your personal [[…/notes/zettelkasten]] (Source, p. 2)

This, however, is certainly not what I want it to look like. It should rather be:

obsidian is an amazing software you can for example use to build your personal [[…/notes/zettelkasten|zettelkasten]] (Source, p. 2)

Proposed solution

When moving or renaming a file, wikilinks adapt the path while keeping their alias - in this case it would mean obsidian adds the ../notes/zettelkasten| information to the link instead of replacing it.

Current workaround

  1. Option 1: After moving the new file, go back to the original file and change the wikilink manually;
  2. Option 2: Every time you create a new (not yet existing) link, change it immediately in a way that it looks like [[zettelkasten|zettelkasten]] instead of just [[zettelkasten]]. This way, whenever you move the resulting file to another folder, the appearance of the original link in edit mode would stay the same.

Option 1 is kind of annoying, option 2 is certainly less dramatic but still more time-consuming as I can’t just double-click a term in order to create a new link.

I guess the proposed solution might, from a coding perspective, be quite easy to implement!? In case this is a bigger deal, this feature request is certainly not the most important one as there are some simple workarounds for the problem.

Yet, both these workarounds are somehow time-consuming and - even more important - especially when it comes to quotations (as in my above example) and I just forget to manually adapt the original link immediately after moving or renaming a file, then in the future I don’t know anymore how the original quotation was exactly - I have to open my book or file and search for the original sentence.

5 Likes

Related use case: I don’t use wiki-style links, I use regular md style: foobar. When I create a link I usually highlight the word I want to use as the caption, hit the “[ ]” button, then select a file. But if the file name I select is not the same as the caption text then the caption text is changed to match the file name. This is counterintuitive and frustrating since I’ve already selected the text I want to be the caption.

I have the same use case as @alltagsverstand

I create a wikilink within my notes and later move it to a different folder. At that point I’m left with an ugly relative path in my old notes.

I noticed that the backlinks plugin already has this figured out! When you go to insert the backlink, it does exactly what alltagsverstand suggested. Obsidian adds the relative path but preserves the original text as the alias. So using backlinks could be another workaround when facing this issue.

You can solve this by using the markdown language for links. For example, to link a note that is titled “Orginal Name” but with the caption “Preferred Name”. You just have to write it this way [[Preferred Name]]([[Original Name]]). Then right-click on the Original Name and copy the Obsidian URL and paste it between the brackets. It will be this way: [Orginal Name](Obsidian URL).

Just in case anyone needs this, there is a plugin that does exactly this. It is called “Smart Rename”. obsidian://show-plugin?id=smart-rename

1 Like

The workaround [[collagen|collagen]] actually does not work (anymore?) in the current version of Obsidian. If the name of the note and the display text are identical, both are changed when Obsidian updates the name of a renamed note.

(this does not actually refer to the post of alltagsverstand anymore but to the initial post. I’m not aware of a way to change that after publishing the post or a clean way of reposting as intended - sorry!)

1 Like

This is indeed weird behaviour which I can confirm - and I would call it a bug, as I cannot imagine any use case where this behaviour would be intended…

OK, so this isn’t a bug, but intended since version 1.2.1. I seem to have missed this update last year - just wondering how much text I already have changed unintendedly to something stupid without being aware of it…

Still, this behaviour does not make much sense to me, at least in 90% of all use cases. I always add separate display text, even if it matches the file name - for the exact reason that my text will be preserved when changing the file name one day.

So one more reason to remember again this more than 3 year old feature request…

3 Likes

Wow it has been 3 years ?
I hope this feature, too

Works perfectly here.

Contrary to @jmdmao, the workaround [[collagen|collagen]] does not work due to the change in ver. 1.2.1 that @alltagsverstand has linked to, which, I agree, was a bizarre decision that broke a perfectly fine workaround.

Though Smart Rename is a stopgap, it’s far from ideal because it doesn’t work automatically—the rename command needs to be run manually. That means that if you want to keep all existing link aliases as is, you have the following options:

  1. Before you rename any note, take a look at that note backlink count—to see whether you need to utilize Smart Rename or not (a step that’s very easy to forget!)
    • Strange New Worlds can be of help here—it can display a backlink count in the top-right of all notes. (Still, it’s easy to miss if you’re not actively on the lookout for it.)
  2. Always utilize Smart Rename any time you want to rename a note (inconvenient and also easy to forget!)

(If utilizing Smart Rename, I recommend pairing it with the Link with alias plugin to create a link like [[collagen|collagen]] with a single hotkey).

  1. When adding a link alias, always ensure that it is not identical to link target—to prevent the auto-rename introduced in ver. 1.2.1. Some ideas on how to differentiate the link alias:
  2. After renaming a file, go through all backlinks and change them manually.

Ugh, this whole thing is just a massive headache… :persevere:


To the Obsidian team:

Please revert the change in question that was introduced in ver. 1.2.1. (Or outline the reasoning for it—what problem did it solve?) Perhaps a middle ground option could be implemented that would go something like this:

If Automatically update internal links is disabled in Obsidian settings > Files and links, add an additional checkbox option to the window below: “:ballot_box_with_check: Also update link display text”.

The checkbox state should be remembered across all modal instances.

Steps to reproduce

As described at Basic note taking: - Obsidian Help

  1. Create a link in a file, preferably inside a sentence. Example:

This means you can [[write naturally]] about [[whatever comes to mind]] and then go back and create the new notes at your leisure.

  1. Follow that link.
  2. Change the name of the file, confirming the change if needed. For example, change the name of the file “write naturally” to “Natural Writing.”

Expected result

I expect the text in the original file to remain the same, but updated to point to the new file using piping, as in:

This means you can [[Natural Writing|write naturally]] about [[whatever comes to mind]] and then go back and create the new notes at your leisure.

Actual result

Instead, what happens is that my original writing has changed, meaning I’ve lost data:

This means you can [[Natural Writing]] about [[whatever comes to mind]] and then go back and create the new notes at your leisure.


Additional information

While I can see some use for the ability to change the original text, surely, with the free-floating writing and linking Obsidian encourages, not changing my writing should be the default.

12 Likes

I like this idea a lot! It would have saved me a couple of headaches.

2 Likes

Agree. That is why I don’t use this approach to writing. Instead I add “See also” section at the bottom of file or add links in brackets after the current sentence.

But I not sure that your proposal is acceptable in all cases. For example, for my files, structured as I described above, i want links to be updated and always reflecting actual filenames.

I think if we want preserve original text of the link in future, we should create this link in special way, e.g. (attention to extra | in link):

This means you can [[write naturally|]] about [[whatever comes to mind|]] and then go back and create the new notes at your leisure.

3 Likes

This means you can [[write naturally|]] about [[whatever comes to mind|]] and then go back and create the new notes at your leisure.

If you do that thing with the extra | in link, Is not a solution because the links will disappear in the preview mode (just tested). It shows like this:

This means you can about and then go back and create the new notes at your leisure.

1 Like

This seems related to my problem of needing to manually create several aliases for one note to a central term, because changing the name of the note would obviously change the text, but I can also not create a new note for every variation of a term (history, historian, historical, historiographical, etc…). "Fuzzy" or truncated aliases with placeholders (otherwise linking is basically neutralized...) - #3 by sonsche

So maybe creating a new page and then aliasing the old term would be a workaround?

Compare these issues: Automatically insert aliases into frontmatter from newly created aliases

1 Like