I recently added Algolia to a project of mine. As this is a public repo, I’m trying to find a way to obfuscate the Algolia API key while having Netlify build.
One solution would be to add a bit of js containing the Algolia options to. gitignore and import it in my layouts using Hugo Pipes.
Because myresources dir is commited, Netlify’s Hugo instance will be able to access the resource on build even if its original asset is not in the repo…
But this feels a bit hackish…
I don’t think you need to worry about obscuring the Read API key (Search-only API Key), necessarily, just the Write key, in which case I don’t think you’d be using Hugo anyway, but a dotenv in JS.
And not to get off topic, but there’s a pretty nice serverless script out there that ensures that you only update what’s changed in your index.