Testing a Hugo Module with Netlify

I had a hard time figuring out how to test a Hugo Module with a PR.

I added the test site in a sub directory and then configured netlify to build from the sub dir.

I added the following configuration:

  • add a . or _ to the start of the sub dir name so its ignored by hugo (go) modules (faster module download)
  • add the following in config.yaml to replace the github module with the parent directory to keep the module up to date as PR’s probably don’t have tags yet
  replacements "github.com/future-wd/hugo-responsive-images -> ../../"

Now when a PR is created, netlify builds the site and I see if it fails.

Does anyone have any advice on how to do more fine level testing on the actual code that is generated by the module? Not just checking for site build failure…

See my example here

FYI, I have some work in progress on unit tests in this repo:

there is a lot more to do on that front, but if you want to be notified of progress on my work on this, you could subscribe to the ticket I have for it:

Hope that we can come up with something good…

I also have some GitHub Actions for standard stuff like Joe Mooring’s audit, HTML validation, and checking internal link (or periodically checking external links, fairly strictly (e.g. 301 will throw an error and complain that the link needs to be updated), which I can provide links if they are of interest, and you don’t already have them, or something like them.

1 Like

Thanks for that. Ill have a good look through it.

I currently dont have any github actions set up so thats a great start!

If i have any ideas for your tests ill let you know