If all my files have unique prefixes (like a datetime stamp), is there a way I can wikilink to it and just show the prefix (i.e. when clicking on the wikilink, it should resolve the rest of the file name for navigation).
Example: 202310111019 - My cool file.md can be wikilinked by [[202310111019]].
If there’s no way to do this via settings or existing plugins, do we expose the API to control how wikilinks resolve file names? I don’t mind making the plugin if possible.
Things I have tried
Navigated through settings, docs, and plugins but didn’t find anything. Willing to create a plugin if API available to use.
I suspect making such a plugin will be not easy, because it will require altering how Obsidian’s core resolves links. I don’t think the Obsidian API lets us do such a thing.
Why do you want to use [[UID]] instead of [[UID - file name]]? With Obsidian’s link auto-completion, typing [[UID - file name]] is as easy as typing [[UID]], I think.
Or, do you just want to change how links look? (Like, [[UID - file name]] appearing as [[UID]])
If so, you can use MathLinks for that purpose (though your use case has nothing to do with math). Just add a property mathLink: <UID here>.
Alternatively, if you have a bunch of notes with wikilinks of the form [[UID]] and want to make them available within Obsidian, it will be not hard to create a plugin (or just a Python script, whatever) that replaces all [[UID]] with [[UID - file name]].
Yeah, I’m really just concerned with how the link looks. Having just the UID present in the link makes the rest of the surrounding text more easily readable, and affords me the opportunity to describe the content of the link in a way that’s more relevant to the current file (title links don’t always “slot” in so well - but still great to have for reference when reading a list of file names).
I see, then MathLinks seems to be the best fit for you!
If you want to avoid typing mathLink: <UID> for all notes, you can make your own plugin using MathLinks’s API!
In fact, I’m the one who made the API part (only that part) and I will be happy to answer any questions about it on GitHub if you want to ask. (Sorry for lacking enough documentation for the API…)
Edit: Currently MathLinks does nothing in Source mode, but I plan to add an option to enable it in Source mode as well.
@bobby Important notice: I’ve decided to completely rewrite the API code (I’ve been thinking about this for a while). This will affect the plugins that use the API. After rewriting (maybe a week later), I will write documentation as well. So can you wait until then if you’re going to use it? (Just ignore me if you’re not )
Update: I made a simple sample plugin to demonstrate the usage of MathLinks API.
It uses currently unreleased APIs, but I will make them available before long.
Your example does get really close. The thing is that I’m normally in source mode and not preview. So the ideal solution would just be [[202310111019]] by itself, so that even in source mode view, it’s very easy to read. I know that’s probably too picky, that’s why I was hoping there was an API I could use to just alter the default wikilink resolution behavior… but sounds like there’s not.
Why don’t you include the UID inside the aliases field in your files?
This way you will be able to display the text of the UID alias whenever you’re creating a link.
In the example you suggested which had the title of 202310111019 - My cool file.md, you could have the following alias field in your yaml frontmatter:
aliases:
- 202310111019
Inside the template of the note, it would look like this:
aliases:
- {{time}}
Now, whenever you’re referencing a file, by typing the UID, the UID alias will also be available. If you select the UID alias it will be shown like this: [[202310111019 - My cool file|202310111019]].
Mainly for when I’m looking at the file names in the file browser, so I can have an idea of what the file is about at a glance.
But just trying to keep the descriptor from cluttering the body of files while linking - since the linked file would theoretically have some other description about how it’s relevant in the given context.