Link multiple words or phrases to a single .md file

Use case: I am reading a main document (.md) where I would like to make certain key-word links to sub-documents.

One example text in the main document is: “three main ways to call AWS APIs.”.

A sub-document would be API.md and to that document I would like to link any instance of the word, word variation or word phrases, such as “API”; “APIs”; “AWS APIs”.

To that document Alias I added : APIs; AW APIs;

In the main document, where there are instances of “AW APIs”, when I select: tools > item links > convert wikilinks to item links, the display updates to show for “AW APIs” : AWS APIs](x-DEVONthink-item://E5C309F4-E877-4BBC-AC00-297B3A5D6C32)

Two links are shown, one does not work (a [ is added), the second jumps to the API document.

Note: " are added to highlight the word. Not using quotes in the words.

Questions: what can I do to achieve my objective? (link multiple words or phrases to a single .md file. (without causing this type of link error to appear))

The source of the document before/after the conversion would be useful.

The source is another .md document.

Also, when I delete the link, the word or phrase are visible with a link. It is only when I run the ‘convert wikilinks’ that it shows the link, as explained.

Show what you’re referring to.

If WikiLinks are working, why are you converting them to item links?

Also, sub-document is your own convention, not a universal term. It would be good to clarify terms or use generally accepted ones.

Discourse uses markdown to format posts. If you just paste directly from the document, all we see is rendered text. Or in this case what looks like half-rendered, broken formatting.

We need to see the raw markdown to understand what is going on. Wrap the markdown source in a code block.




"why are you converting them to item links? " As I have read in multiple instances, item links are more persistent when moving them around. I will eventually move the documents around.

Sub-document, yes, my convention, used as a way to distinguish the main document with mixed topics, and the separate document where I am focusing on one topic.

You define an alias consisting of multiple words. One of those words is already defined as an alias on its own. I’m not sure how you expect that to work?

You have created a situation with conflicting aliases / multiple matches for the same string.

I guess one could imagine WikiLinks would prioritize the longest of the aliases. I don’t know how this works under the hood and if that is feasible.

Here you instead get 2 links – one for the alias AWS APIs, one for AWS, but tangled up in each other.

What are your WikiLinks settings?

  • Relative or absolute links can break if you are moving things around.
  • WikiLinks are persistent within a database.
  • Item links can persist across databases.

In the aliases: APIs; AWS APIs;
The one that is causing problems is the AWS APIs, because, as mentioned by @troejgaard, the world APIs is already mentioned. I tried adding quotes “AWS APIs” to distinguish as a separate word/phrase but that did not work. Can you suggest another method?

I would like to treat instances of API; APIs and AWS APIs as separate but linking to the same document. Perhaps it is not possible in a simple way.

Why do you have both Names and Aliases and Square Brackets enabled? It’s more common (and controllable) to use one or the other.

Maybe I was a bit too fast.

I never really started using aliases. I do uses WikiLinks some of the time. But I don’t have a lot of experience with how they interact.

I think the problem is that you have enabled “Names and Aliases”. This detects WikiLinks based on matching names and aliases everywhere in the text automatically.

It works here if I only enable square brackets. Then you define the string boundary yourself, and DT doesn’t automatically detect 2 aliases in the same string. (I’m still on DT3 if that makes a difference)

I just gave a random document the aliases Test Alias; Alias.

Before converting to item links:

[[Test Alias]]

[[Alias]]

After:

[Test Alias](x-devonthink-item://EC31BBCF-8C73-41B3-9C49-E9C4B0F70719)

[Alias](x-devonthink-item://EC31BBCF-8C73-41B3-9C49-E9C4B0F70719)

My workflow is:

  • As I read, I see a word or phrase from which I would like to create an .md (so that I can gather there pertinent information about the topic).
  • I select that word or phrase and have a setup a KeyboardMaestro keystroke that places brackets [ …] around it.
  • Click on the bracketed item to create an .md document.
  • In that new .md I will add related text to the Alias.
  • Then I convert the Wikilink to an Item link.

This way, when I open any document that has the word or phrase (or aliased words), they show as a link to the .md

Here is a potential solution to the multi-linking and fully MultiMarkdown supported…

Define a link with link text as shown. In this case, both are pointing to the same document. You just need to use single square brackets to use them.

1 Like

Brilliant! Thank you.

You’re welcome. I’m glad it’s a useful technique for you. :slight_smile:

Another thing worth raising (though I am sure you are aware) is that in settings -> wikiLinks you can create a template for a document if it doesn’t yet exist.

So you can put [[ ]] around a word/phrase then click on it and a document will be created to the template you have defined in settings. Using placeholders you can set things like a title, creation date or a link back to the source document.

https://discourse.devontechnologies.com/t/wikilinks-and-placeholders/63199

1 Like