[Solved] Jekyll simple search display no results

Hi all

Hi! I’m trying to implement the istant search in my site found on GitHub

I followed all steps, I can see in _site that search.json file, is correctly fetching results and being populated, but I can see no results displayed in the live page.

I need a little help on where to put these parts, because I have

_posts
| -blog
| -wiki

I tried to add the below code in _layout , in default.html, in page.html. and in a single search.html page

<script src="{{ site.baseurl }}/js/search-script.js" type="text/javascript"></script>
<!-- Configuration -->
<script>
SimpleJekyllSearch({
  searchInput: document.getElementById('search-input'),
  resultsContainer: document.getElementById('results-container'),
  json: '{{ site.baseurl }}/'
})
</script>



<!-- Html Elements for Search -->
<div id="search-container">
<input type="text" id="search-input" placeholder="search...">
<ul id="results-container"></ul>
</div>

Inspect console shows this

immagine

While I copy pasting the code, doing some test, it worked for a while, but I’m not able to reproduce how I did

I have a testsite here

realware

Thanks for any help

I have not used it so this may not be good advise:

Is your site hosted on GH? maybe the plugin is the problem?

Maybe also try using the non minified version of the js - it doesn’t look right to me. I think this is the problem.

Hello,

The site is being built correctly on GitHub, instead you had a good idea and put me on the right track, the version that worked was the regular one and not the minified.

I’ll do some tests!

Update:

Solved: You were absolutely right!

For future reference: the minified version contains some errors, I found a forked repo with a rebuilt version of the js, just remove the big comment block in the end of the file because links to external resources not needed

Simple-Jekyll-Search

Thanks for your advice @rdyar