Forum Moderators: not2easy

Message Too Old, No Replies

Have a simple static site how to implement search?

         

born2run

6:11 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi so I have a simple static site which is like a list of links of news articles (like google news). Is there any way I can add a search function onto the site? The webhost technology is LAMP. The results would be any of the links which match. Thanks!

not2easy

6:43 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Take a look at the search on this site. it is in the upper right on desktop or go to [webmasterworld.com...] but that page does not include DDG for some reason, while the search box does.

It seems you can get the same kind of search for your site if that will answer the need. You would need to integrate with code from each search engine you want to use so just visit the search sites and they usually have a page telling you how to integrate their code.

not2easy

7:11 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Here is an example - I opened a browser window and entered "how to add DuckDuckGo search to my site?" and the first result was a link to https://duckduckgo.com/search_box with all the information for settings, styling and URL parameters you would need. You choose how you want it to look, add the name of the domain you want it to seach on and then take their iframe code and add it to your site where you want to have the search. I would imagine that Google, Bing and Yahoo search all offer similar help.

born2run

7:12 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Actually my site has a single page. This single page (url) has a list of links (a href). I want to search from within those links (title) and the the results page would show those specific links only (from within that single page).

graeme_p

8:28 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If its just a single static page you might find easiest to do it with JS, which would keep it a static site, and should be relatively easy to do if you can fine an appropriate existing bit of JS to do it.

I assume that as you mention you have the LAMP stack available you do not have to keep it a static site, so you could do it in PHP (or something else depending on what else the host has available) as there are search engine scripts around.

I suspect the first approach is the simplest for a one page site.

lucy24

11:41 pm on Jan 1, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What's your target audience? Are you looking for a solution that will work for users to dim to use their browser's Find function within a single page?

tangor

3:58 am on Jan 5, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's a difference between site search and web global search. You can install an actual SEARCH ENGINE for your site such as Perl, PHP and a few others, just search for INTERNAL SITE SEARCH PROGRAMS (caps not required).

HOWEVER, The cut and paste options from bing, g, ddg and others often does what you want and refrains from building a large index (database) on your site resources, which is generally 1.5-2.0 times the size of your actual site. HOWEVER, the BENEFIT of an internal site search is your visitor will NOT see, by accident or unusual response from the global entities, a link that will take your USER to a different site than yours.

THAT SAID, the cut and paste offers from the big SE's really does a great job and YOU are saved the cost of the index database on your resources.

vivalasvegas

6:53 am on Jan 5, 2021 (gmt 0)

10+ Year Member



I've been studying Javascript watching some nice tutorials, and this one tutorial I like the most includes a practical lesson on how to build a simple search to use on a single page. Pretty easy and fun to do. If you're interested PM me and I'll give you more details.

Swanny007

6:07 pm on Jan 5, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I use the DuckDuckGo search box on my static site too. I like that I can match colors on the landing page. I highly recommend DDG search box.

born2run

11:58 pm on Jan 16, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hmm so I'd have to have a js script.

NickMNS

2:34 am on Jan 17, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@vivalasvegas
I've been studying Javascript watching some nice tutorials, and this one tutorial I like the most includes a practical lesson on how to build a simple search to use on a single page.

Are you referring to a single static html page or a single page app, those are two very different things.

@born2run
What do you want the search function to do? Do you want the search to scroll to the point in the page where the searched content is found? And what type of search algorithm do you want, exact match, or match to some degree of similarity? What if there is more than one match found?

born2run

10:08 pm on Jan 17, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So ok for now let’s say the page has two links to external websites. One link has Title 1, other Title 2.

So the search script should search for text matches in the link title. The results would be a list of links with matching titles.

lammert

12:18 pm on Apr 9, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't know if the search functionality has already been implemented, but with a single page site, the text message Hit Ctrl-F to search this page should be cross-browser compatible without adding any JavaScript. When visiting large pages I have never thought of using an on-site search box. I use the browser built-in search function instead.

lucy24

5:42 pm on Apr 9, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hit Ctrl-F to search this page
Or, ahem, cmd-F. (They are separate keys, so unlike alt : opt they can’t be treated as dialectal variants.)

Edit: I just noticed this is the Mobile subforum. On a mobile device, page search exists in some form, but it's a lot harder to achieve.