β Scan for markdown broken links in your blog
β’ 175 words β’ 1 min β’ updated
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:
% 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.
-
I ceased to use
blog.perrotta.devin favour ofperrotta.devin Q4 2024. ↩︎