Static sites like Hugo don't have search engine features natively integrated, so you need some external tool, like Lunr or the most recent Lyra. In this article, I'll explain both the projects, how they work, and what I've learned building it. You can follow the README to get started:
https://github.com/paolomainardi/hugo-lyra