I, like many others before, am trying to implement lunr search on my hugo site.
I have, by following many of the posts on the topic, built the necessary json file for input to the index builder. I wish to pre-build the index and include that prebuilt index in the assets of the site in /public.
There are plenty of js code examples for pre-building, but as far as I can see, there is no way to have the pre-build occur during the build process, so that the index is bundled with the site.
I have a bash script that creates the Hugo website and then runs the script that uploads my just created index to Algolia and then removes the built from the site (no need to have a 10mb json file available online). Hugo has no hook system that you could use to run something after it built the site.
I have a wrapper bash script in which I call hugo. Optional pre/post processing can happen in that script. On Netlify, I change the command to call that script instead of directly calling hugo.