EDDYMENS

Last updated 2022-07-18 14:49:04

How To Reuse Links In Markdown (reference Links)

01: β–„β–„ β–„β–„ β–„β–„β–„β–„β–„β–„β–„β–„β–„β–„ 02: β–β–‘β–‘β–Œ β–β–‘β–‘β–Œβ–β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œ 03: β–β–‘β–Œβ–‘β–Œ β–β–‘β–β–‘β–Œβ–β–‘β–ˆβ–€β–€β–€β–€β–€β–€β–€β–ˆβ–‘β–Œ 04: β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œβ–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œ 05: β–β–‘β–Œ β–β–‘β–β–‘β–Œ β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œ 06: β–β–‘β–Œ β–β–‘β–Œ β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œ 07: β–β–‘β–Œ β–€ β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œ 08: β–β–‘β–Œ β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œ 09: β–„ β–β–‘β–Œ β–β–‘β–Œβ–β–‘β–ˆβ–„β–„β–„β–„β–„β–„β–„β–ˆβ–‘β–Œ 10: β–β–‘β–Œβ–β–‘β–Œ β–β–‘β–Œβ–β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œ 11: β–€ β–€ β–€ β–€β–€β–€β–€β–€β–€β–€β–€β–€β–€

Sometimes you need to use the same URL in different parts of your markdown document and this can be a pain when you need to make changes.

You can search and replace using your text editor. However, if the same link is missing the HTTPS: protocol or www in other places this might not work well.

Markdown has a syntax for reusing links called a link reference.

This involves defining the link or URL by using the following syntax: [link name]: link.com. You can place this definition anywhere in your markdown file. The markdown parser will not render this onto the screen.

You can now use this reference link like so [ description text][link name]. Note how square bracket [] is used in the second part as opposed to the parentheses () you will use when creating a normal markdown anchor link.

Below is a complete example

01: This first line uses the link [here][link] 02: 03: This second line uses the link [as well][link] 04: 05: [link]: https://www.example.com
  • Easy to update links: If you ever need to update a link used in different places you will only have to update the reference definition.
  • Friendlier markdown links: because you get to name your reference whatever you want, you can use names that carry meaning regarding what the link is for. This makes it more pleasant for people reading the actual markdown document.
  • Broken link capture: whenever you use a reference link the parser checks to see if the referenced URL was created before rendering it as a link. This means if the reference does not exist you will quickly notice it, as your page will contain meaningless square brackets.

Here is another article you might like 😊 "Diary Of Insights: A Documentation Of My Discoveries"