Here’s a small Python script that creates a JSON page index file for use with algolia/docsearch.
I am using it while developing my Hugo site while it is hosted locally.
You can set up your config.yaml
to contain your Algolia App ID, API key and the index you want to use as follows:
params:
algoliaappid: <your appId>
algoliaapikey: <your API key>
algoliaindex: <your index>
and the following HTML
docsearch script and css
<script type="text/javascript" src="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
snippet for the search box:
<input type="text" id="search-input" />
<script type="text/javascript">
docsearch({
apiKey: '{{ .Site.Params.algoliaapikey }}',
indexName: '{{ .Site.Params.algoliaindex}}',
inputSelector: '#search-input',
appId: '{{ .Site.Params.algoliaappid }}',
debug: true
});
</script>