In Markdown, I’m using reference-style links like [text][ref] and defining the URL once. But instead of showing just the link text, I want to display the actual URL inline (e.g., website (https://example.com)) without writing the URL multiple times.
Is there a way in Markdown to show the URL from a reference link? Looking for a clean solution using markdown link syntax.
I ran into the same thing when documenting API links.
Markdown doesn’t let you reference a link and also display the URL unless you manually repeat it. So I ended up doing this:
This website (https://www.lambdatest.com)
is awesome.
It’s not DRY, but at least it’s obvious to readers. Sometimes I combine both:
This [website](https://www.lambdatest.com) (https://www.lambdatest.com)
.
Not elegant, but it works for PDFs or plain viewers.
I was trying to show the URL only once but still keep the link reference in Markdown. I ended up using backticks to visually separate the link like this:
This [website][ref] (
https://www.lambdatest.com`).`
[ref]:https://www.lambdatest.com
It doesn’t automatically pick the URL from the reference, but at least it reads nicely.
Sadly, Markdown doesn’t support dereferencing link labels like a variable.
Honestly, when I needed full control, I just used HTML inside Markdown:
This website (<a href="https://www.lambdatest.com">https://www.lambdatest.com</a>)
is great.
Most Markdown renderers allow inline HTML, so this gave me flexibility without repeating the URL in a clunky way.