thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

β˜… Scan for markdown broken links in your blog

β€’ 175 words β€’ 1 min β€’ updated

⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.

Link rot is a real problem in the web, even though Cool URIs don’t (supposedly) change.

I figured I could try to mitigate it from my site from time to time with some CI integration.

Then I found markdown-link-check.

The best way to illustrate its usage is with an example:

shell
% pre-commit try-repo https://github.com/tcort/markdown-link-check --all-files
[...]
FILE: content/posts/2024-02-04-new-domain.md
  [βœ“] https://www.perrotta.dev/
  [βœ–] https://blog.perrotta.dev/
  [βœ“] https://perrotta.dev/
  [βœ“] https://thiagowfx.github.io/

  4 links checked.

  ERROR: 1 dead links found!
  [βœ–] https://blog.perrotta.dev/ β†’ Status: 0

FILE: content/posts/2024-12-30-cookiecutter.md
  [βœ“] https://github.com/cookiecutter/cookiecutter
  [βœ–] https://crates.io/crates/kickstart
  [βœ“] https://github.com/Keats/kickstart?tab=readme-ov-file#050-2024-12-13

  3 links checked.

  ERROR: 1 dead links found!
  [βœ–] https://crates.io/crates/kickstart β†’ Status: 404
[...]

It compiles an exhaustive list of all broken links in all markdown pages in my git repository1.

It’s not bullet-proof. For example, sites behind Cloudflare are reported as broken, even though they may not be (example). Sites that block bots / crawlers may also be flagged as false positives.

I added it to the list of pre-commit hooks for this site.


  1. I ceased to use blog.perrotta.dev in favour of perrotta.dev in Q4 2024. ↩︎