Option to clean up Relative and Absolute Links by default

I prefer using “Shortest path when possible” with my internal links. But when I consider compatibility with other editors and viewers, I’m feeling the need to switch my settings to “Relative path to file”.

Some people want to see all the information in the preview. Some people don’t.

It would be great to have an additional setting that auto-generated a pretty link in our markdown when these long link formats are set.

For example,

When [[Review Cafe]] is entered in Edit mode, currently this is generated:

[[../Meta/Templates/Business Reviews/Review Cafe]]

but with a new setting it could generate as:

[[../Meta/Templates/Business Reviews/Review Cafe|Review Cafe]]

So that in Preview, this

Here is the …/Meta/Templates/Business Reviews/Review Cafe template.

becomes the clean and legible:

Here is the Review Cafe template.

Of course we can modify it, but this would be a welcome default on long links to keep our Previews clean and easy to read.

Related

This pipe format may be a simpler solution that this

15 Likes

I would also like this for exactly the same reason.

2 Likes

One thing I will add, is that this is already how Markdown style links function.

[type 1 lsa](tech/network_engineering/type%201%20lsa.md)

will be rendered as

type 1 lsa

in the preview.

1 Like

An issue that I’ve noticed with either using standard markdown links or Obsidian’s “Wikilink Pipe” to change the appearance of the text in preview mode is that when the file that the link points to gets renamed the “pretty” text does not get renamed as well.

I can see situations where it would be preferable for it to be renamed too, as well as others where it would not.

I was originally using relative markdown style links out of concern for compatibility with other software, but once I noticed the pretty text not being renamed I gave up on that. I now use wikilinks & “shortest possible”. It’s the only way that I’m guaranteed that the pretty text will always be the same as the file name.

I reasoned that with a proper markdown export as well as a mobile app on the way, if I ever needed to work on something with a 3rd party app that I could just export it as proper markdown.

Although I’d definitely much prefer an option that would allow me to use 3rd party software without having first to export it to proper markdown.

2 Likes

Use case or problem

When creating new links, I use the Absolute path in vault setting under Settings > Files & Links > New Link Format because I like to see exactly where a file lives in the vault.

I also find myself manually adding the page title after that so it looks nice when I preview it, so for example:

[[People/Smith/John Smith|John Smith]]

I’d like to see a way to have the page title automatically appended to the link so I don’t have to do it manually.

Proposed solution

Add another toggle to the Files & Links page, Add page title to auto-generated internal links or something, which when enabled, would mean auto-generated internal links would go from [[People/Smith/John Smith]] when inserted, to [[People/Smith/John Smith|John Smith]] when inserted

Current workaround (optional)

Currently doing it manually. It’s not too difficult, but it gets tedious when I’m working with a lot of links.

Related feature requests (optional)

3 Likes

I agree with the feature request, sounds like a good idea.

You could make a slightly better workaround by using Templater and hitting one hotkey to automatically update your links.

Assuming your cursor is directly after a link having just inserted it, the Templater script would:

  1. Read the contents of the file up to the current cursor position.
  2. Regex to find the page name of the last link in the contents.
  3. tp.file.cursor to move the cursor to the left of the closing link ]]
  4. tp.file.cursor_append to add |Page title
  5. tp.file.cursor to move the cursor to the end of the link again

You could make this even more efficient by putting your own file-chooser in the script and using your hotkey to insert all links, but you might just want to augment the default link inserting rather than replace it.

1 Like

will be implemented v1.2

2 Likes

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