Hugo: Feature suggestion: add indexing with algolia

Created on 19 Nov 2017  路  3Comments  路  Source: gohugoio/hugo

Hi,

I am loving using hugo for websites and am currently using algolia to index my pages.

I have currently implemented it by dumping indexed documents as json and running a curl script to upload all json documents afterwards.

my config.toml looks like this:

[outputs]
    page = ["HTML", "RSS", "JSON"]

the template looks like this:

{
    "title": {{ .Title | jsonify }},
    "date": {{.Date.Format "2006-01-02"| jsonify}},
    "plain": {{.Plain | jsonify}},
    "summary": {{ .Summary | jsonify }},
    "reading_time": {{.ReadingTime | jsonify }},
    "objectID": {{ .RelPermalink | jsonify }}
}

and the curl script looks like this:

find public -name drafts -prune -o -name 'index.json' -exec curl -X POST -H "X-Algolia-API-Key: ${API_KEY}" -H "X-Algolia-Application-Id: ${APPLICATION_ID}" -d @{} "https://${APPLICATION_ID}.algolia.net/1/indexes/${index}" \;

I was wondering if there would be an opportunity to get this indexing done by default by the engine, having a config.toml like

[index]
  algolia.outputs = ["page"]
  algolia.index = <indexName>
  algolia.application_id = <ID>

And find a solution not to have the secret in the config.toml (command line? environment variable? from a file?)

I would be happy to help having this feature if you think it is interesting for the engine

Stale

Most helpful comment

Curious: Why do you output one JSON per page? Would it not be better to dump all pages into one JSON?

As to adding this to Hugo, my initial thought is: Not now. Maybe when we get some "processing pipeline" in place, and then hopefully also with some plugin support.

All 3 comments

Curious: Why do you output one JSON per page? Would it not be better to dump all pages into one JSON?

As to adding this to Hugo, my initial thought is: Not now. Maybe when we get some "processing pipeline" in place, and then hopefully also with some plugin support.

Indeed it would be better, reducing the number of requests at the same time
There are no much more reason than the first thing I got to work

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Was this page helpful?
0 / 5 - 0 ratings