None
NL
Use Hugo Output Formats to generate Lunr index files for your static site search
['Bart De Goede']
Bart de Goede
The search on my blog lives on the homepage, where some (very ugly) Javascript downloads the index file, parses it contents into an inverted index, and replaces the content on the page with search results whenever someone starts typing. Now, I don’t want that index.json file to basically be the list of links it is in the HTML version and in the RSS feed, so I added an index.json file in my layouts folder with the following content: [ {{ range $index, $page := .Site.Pages }} {{- if eq $page.Type "post" -}} {{- if $page.Plain -}} {{- if and $index (gt $index 0) -}},{{- end }} { "href": "{{ $page.Permalink }}", "title": "{{ htmlEscape $page.Title }}", "categories": [{{ range $tindex, $tag := $page.Params.categories }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}], "content":…