How to add a search bar?


#1

How we can add a search bar in Jekyll website.


#2

See these tutorials on search from CloudCannon: https://learn.cloudcannon.com/jekyll-search/


#3

Here is an example of a super simple site-search (using Google):

<form method="get" action="http://www.google.com/search" target="_blank">
<input type="hidden" name="sitesearch" value="ibkc-carrosserie.nl" />
<input type="text" name="q" maxlength="255" placeholder="Search with Google" />
</form>

Note that the domainname needs to be changed (currently ‘ibkc-carrosserie.nl’). See the full code at: https://github.com/jhvanderschee/oocinfo/blob/master/_includes/footer.html. The live website can be found here: http://ibkc-carrosserie.nl/.


#4

You can use a Javascript search like lunr.


#5

i have made a search feature for a Jekyll shop. using this method shown here

http://kushagragour.in/blog/2015/06/search-in-jekyll-blog/


#6

So, if we add the search bar on what basis it will show the search results?

On the basis of category or tags or keyword?


#7

On build it will build an xml file to search… I used a bit of ymal call search terms


#8

I have tried to add the search bar. But it didn’t go well.

Is there any other option?


#9

Have you looked into Algolia?

There’s a Jekyll plugin to auto-sync data from a standard Jekyll blog (link).

If you’re doing more than a blog, a quick search on Github will pull up a number of results (including a few I’ve made over the years). I’d recommend starting with their instantsearch library.


#10

Algolia it is quite expensive.


#11

They have a free tier for open source projects.


#12

Currently I have 380 blog posts on my website.

When I run the command jekyll algolia, it upload all the data to Algolia website and turn out, it filled 8100 queries from 10000.

Which is not a good?


#13

So, I use Lunr.js and it worked perfectly, free and open source project.


#14

I have over 1000 posts on my site and haven’t max’d out any of the free tier.

Lunr is fine. Algolia in my experience does a better job and is more performant.


#15

How did you do that?


#16

I’m not doing anything special, just jekyll algolia same as you.

I’m using 2,790 / 10,000 records and about 525 search queries in the last 24 hours. My understanding is the records are tied to the posts and their data. Add more posts and that goes up.

Queries depend on how active your site is and the amount of searches performed.

Your records seem pretty high for having a fourth of the posts I have. Maybe login to your Algolia dashboard and check the indices.


#17

Yeah, it is 8375 records.

Here’s the records

chrome_2018-08-05_13-14-03

Here’s the indices

2018-08-05_13-17-17


#18

Seems a bit high to me. What exactly is it indexing? Do you have a lot of attributes?

For reference I have a ton of posts and are no where close to hitting 10,000.

Looks like for me it’s indexing about 10 attributes per post (title, content, tags, type, date, excerpt, slug, url, etc.) on my site.

Maybe you could leave an issue on the Algolia plugin’s GH to inquire how to reduce the records indexed.


#19

Attributes

image

image


#20

There’s your issue. Didn’t you say you had less than 400 posts? According to what Algolia is indexing you have over 8,000.

Explains why you’re almost at 10,000 records.