Adding Search to Hugo with Pagefind

How to add search to a Hugo static site with Pagefind. No backend, no JSON templates, no pain. Just one build command and twenty lines of code.