AI Workshop: learn to build apps with AI →
Tips: Fix .md in links

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


Using Obsidian to edit my Markdown files, I’ve started to link lessons using Obsidian’s own internal linking.

It’s great because with Obsidian link tracking I can move a file around, change folder or filename, and links don’t break.

Links however use a .md extension, since we’re linking markdown files here.

[3-absolute-positioning](../css-positioning/3-absolute-positioning.md)

So since I’m using Astro, links don’t work as they point to a URL ending with .md.

I found this rehype plugin for Astro: https://github.com/vernak2539/astro-rehype-relative-markdown-links

It fixes this exact problem and I’m so grateful this exists, but it didn’t work with Astro 3 (at the time of writing) and required Astro 2. Maybe now it’s updated.

Anyway since it’s a single file I copied the file locally and imported it in my Astro config.

Only thing I noticed is, maybe because I use content collections, my content collection path was prepended to URLs now, so I hardcoded a little custom fix in the code that only works in my use case, but well, job done.

Lessons in this unit:

0: Introduction
1: ▶︎ Fix .md in links
2: Moving a simple site to Astro
3: Astro, fix Form error “Content-Type was not one of…”
4: Astro page layout and middleware execution order
5: Astro, set caching headers
6: Astro, set response header
7: Deploying an Astro + PostgreSQL app on Railway
8: Using Astro locals
9: Using Cloudflare Turnstile on an Astro form
10: Using reCAPTCHA on an Astro form
11: Why not write logic in Astro layouts