Skip to content
Sign upLog in
← Back to Community

How to make simple html/JS search engine

Profile icon
KellerWorthen

I am wanting to make a search engine that will search just my website to make it more accessible.
Anybody have ideas on how to do this?

Voters
Profile icon
AniV19
Profile icon
MercedesElliot
Profile icon
k9chelsea2
Profile icon
KellerWorthen
Comments
hotnewtop
Profile icon
Coder100

Hello. Here's the thought process:
First, you index all your pages in a js file:

const pages = [{ url: "[url here]", keywords: ["key","words","here"] }];

And then, to get some search results, you can just do:

let search = "[get user input]"; array.filter(page => page.keywords.some(keyword => keyword.includes(search)))

Hopes this helps!

Profile icon
KellerWorthen

@Coder100
I'm not sure I understand.

Profile icon
Coder100

what part?

@KellerWorthen

Profile icon
KellerWorthen

@Coder100
Most of it... Did I mention I suck at JavaScript?

Profile icon
seanlnge

If it is only searching your website, you can create an array of all of the pages and then create a function that returns a few of those options.

Profile icon
k9chelsea2

good question I have no clue lol

Profile icon
RixTheTyrunt

Me too XD