GitHub Action to validate shortcodes, image links, and internal page links

I’m new to Hugo. I’ve been using it for a couple of months now. And I’ve really gotten into using shortcodes to streamline posting.

As someone with dyslexia, I tend to make a lot of type-os and while building hugo catches some of them. Image links and links to other internal pages will just get deployed. I built out a quick GitHub action that validates the following:

  • in the front matter: featured_image and recipe.image (from my recipe card shortcode) really exist in the page bundle.
  • in the MD: internal image references are available.
  • in the MD: internal hyperlinks to other pages are validated for existence.
  • in the MD: shortcodes are validated that they exist in /layouts/shortcodes/

This all works for my approach to using hugo but I get there are other ways to structure your site. I tried to look for prior art but the closest thing I could find was archived 6 years ago. I threw it on GitHub in case it helps anyone else.

Hope it helps!

1 Like