Search Results issue

Hi all this is my index.json in /layouts/

I dont want to index the content of each page, only the tittle,description and tags should be searchable. If i remove the last link with the content, the search functionality stops working.

{{- if ne $page.Type “json” -}}
{{- if and $index (gt $index 0) -}},{{- end }}
“uri”: “{{ $page.Permalink }}”,
“title”: “{{ htmlEscape $page.Title}}”,
“tags”: [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}],
“description”: “{{ htmlEscape .Description}}”,
“content”: {{$page.Plain | jsonify}}
{{- end -}}
{{- end -}}]

Which theme are you using?

In case you are using learn theme, you have to edit some javascript
Find the initLunr function in search.js file and delete the below part.
I’m not tested it.

주석 2020-02-13 005919

i tried it but now search does not work it says index.json cant be download (status failed) from chrome dev console

If I were you, I would find content related code in the search.js and delete it. I can’t tell you more detail. You should find it and delete it

thanks fixed it but for some reason the index.json fails to load when i visit the site (works fine on localhost)
i think it has to do something with cross origin (CORS)

I suspect the baseurl has wrong value.
Debug what value is in the baseurl and check yourbaseurl + index.json in the browser. If it gives the json file, the search should work

The baseurl is from your config.tomlfile.

{{ if .Site.IsMultiLingual }}
        var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
    {{ else }}
        var baseurl = "{{.Site.BaseURL}}";
    {{ end }}

the baseurl is correct, i tried with a cors chrome plugin
when i switched it on, the search functionality works fine.
so its definetely something with the cross origin

@zzo any idea?

still did not find any fix

any help?