Internal Links ignore Aliases

Hi,

When using the auto-complete link tool, and typing the alias of a link, it is created in the format:

[[note_name|alias]]

I would like to not include the |alias part, since I just use the alias to quickly find the reference.

Is it possible?

2 Likes

@Juketo : apologies for the long answer to an easy question. I started answering, and it kind of snowballed. So anyways, one workaround would be to occasionally run a mass search and replace, searching for |alias]] and replacing with ]]. I use VSCode for this type of thing. There is a feature request for mass search and replace within Obsidian, if you are interested. You could also search for |alias and replace with nothing; however, in the first solution, using the double closed brackets probably better avoids false positive matches. Still, it is possible, so be careful with this.

I can think of one other hacky option that is probably more harm than it is worth, but I will share it anyways because it provides some value. This solution is kind of assuming your main gripe with aliases is that you lose the full note name when in preview mode. To begin, rather than creating an alias, you could create a heading within the note with the name of the alias. Then, when you want to add the link, you could press [[## which tells Obsidian you only want suggestions for headings. You could begin typing the alias, and press Enter once you have the correct heading suggestion highlighted.

Of course, now you will be linking to a heading rather than just the note. Rest assured that the link will be updated if you rename the note. However, as of now, the heading of the link will not be updated if you change the heading name within the note. This is not the end of the world, as your link will still take you to the note, and Obsidian will likely help you spot this issue eventually. I am referring to the Page Preview core plugin. If enabled, your page preview will say “Unable to find section alias in note_name”. With a little patience, we will see headings automatically updating. This is on the roadmap and is going to be awesome. Until then, this warning will tell you it is time for a mass search and replace to correct the changed heading names across your vault.

Since you have read this far, assuming you are not against hacky solutions, I would recommend you may just want to just stick with aliases and put together a macro solution. I am no expert at this, but, for example, you could keep all of your aliases at x number of characters in length. Even if that means adding a few underscores at the end, that is fine. Following this convention, you could have a hotkey for your macro that you would trigger when the alias suggestion is highlighted. This would press Enter, Left arrow, Left arrow, Backspace x+1 number of times, Right arrow, Right arrow. The +1 is to remove the |.

Or, if your aliases are only one word or words separated by underscores, the macro could be Left arrow, Left arrow, ctrl shift Left arrow, shift Left arrow, Backspace, Escape, Right arrow, Right arrow. The Escape is to close the suggestions and avoid any possible unintended linking snafus. However, if you refrain from typing after triggering the macro, Enter would probably work just as well.

Anyways, I went through all of this not because I think it that super helpful for your particular issue. I just think that some of these solutions work reasonably well, and at the very least this does highlight Obsidian’s not so obvious ability to get heading auto suggestion links by pressing [[##. It also perhaps introduces someone out there, if not you, to the wonderful world of easy to setup macros. Personally, I was introduced to macro programs including AutoHotKey here on this forum by @ryanjamurphy (many thanks) and since then I have been able to use them for all sorts of creative problem solving. Just be careful, and backup often. Also beware of running loops that use the Delete key, or at least learn how to quickly exit the macros if possible. I only say this because I have learned of these potential dangers from a very scary runaway macro experience. That is all I will say.

Hopefully, there are likely more elegant solutions that either already exist or are on their way. Good luck finding them.

Thanks.

1 Like

First of all, thank you for your effort while writing this reply, I-d-as. I really appreciate it.
However, as you anticipated, I was looking for a more native way of doing it.

For my specific case, it is not that bad. As I use aliases for shortcuts, the automatically created links result in something like [[Long Note Name|lnm]]. So, in the end, it is just 2 or 3 more letters.

Thanks again for these great workarounds, but unfortunately, the solution for me would have to be a native option.

1 Like

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