On the Hugo documentation site we use a link render hook that performs real-time validation of internal links, including fragments (e.g., /functions/foo/#something). It is based on this code with the addition of some special handling unique to our documentation site.
With the amount of content restructuring we’ve done over the last 18 months, and the restructuring currently in progress, this hook is (at least to me) essential. Getting immediate feedback when, for example, you change the name of heading, saves a lot of time. If you only check your internal links periodically, you can end up with what I would describe as “stacked” broken links that can be a hassle to fix.
For external links, validation prior to or during deployment is sufficient.