Conflicting file name: layouts/index.json
#726
-
Hello, I tried to create separate JSON file to upload to Algolia.
File
Whatever I do, newly created Finally, I realized that using name The issue disappeared only when I started using whole local copy of theme and made changes directly to the theme. I started seeing what "algolia" template supposed to produce. I think Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Oh, sorry about that, I forgot the Hugo look up order totally. In this case, you'll need to place your template to Move the JSON template to And the template syntax seems outdated, can't build, I modified a bit to make site buildable. {{/* Generates a valid Algolia search index */}}
{{- $.Scratch.Add "index" slice -}}
{{- $section := $.Site.GetPage "section" .Section }}
{{- range .Site.AllPages -}}
{{- if or (and (.IsDescendant $section) (and (not .Draft) (not .Params.private))) $section.IsHome -}}
{{- $.Scratch.Add "index" (dict "objectID" .File.UniqueID
"fuzzywordcount" .FuzzyWordCount
"keywords" .Keywords
"permalink" .Permalink
"title" .Title "type" .Type
"url" .Permalink
"section" .Section "tags" .Params.Tags "categories" .Params.Categories )}}
{{- end -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}} Hope this helps. |
Beta Was this translation helpful? Give feedback.
Oh, sorry about that, I forgot the Hugo look up order totally.
In this case, you'll need to place your template to
layouts
folder to get higher priority.Move the JSON template to
layouts/home.algolia.json
should works.And the template syntax seems outdated, can't build, I modified a bit to make site buildable.