[Solved] Cloudflare Pages Failed with 'function "warnf" not defined' (PaperMod theme)

I’m switching from Netlify to Cloudflare pages and ran into an error building one of my sites:

Error: “/opt/buildhome/repo/themes/PaperMod/layouts/shortcodes/collapse.html:3:1”: parse failed: template: shortcodes/collapse.html:3: function “warnf” not defined

I can see from @sparky’s post that it could be fixed on Netlify with a config file (/t/solved-function-warnf-not-defined/31897) but this won’t work on Cloudlfare pages.

Building the site on Netlify and locally produces no errors (even without a toml for Netlify).

The way to fix this error is to make sure you specify the Hugo version as a variable in the build settings:

(for example) HUGO_VERSION 0.96.0

https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site/