Variables in Markdown

11-03-2020

I recently needed to create a Markdown document that contained the same couple of values throughout the document. The developer in me hates to copy/paste anything more than a couple of times if it has the potential to ever change. So I looked for a way to assign a variable in Markdown.

The idea is pretty simple, Markdown has a concept of reference links or reference-style links that allows us to define a value to a reference variable and then refer to that value later in the same document.

1
2
3
This is my [random value] located somewhere in my Markdown document.

[random value]: variable value

In this example the [random value] will be replaced with the “variable value” anywhere it appears. A simple, yet powerful way to approach Markdown.