Need to add a search to static HTML site

directory, forms, html, php, search

Solution

There are quite a few solutions available for this. In no particular order:

Free or Open Source

- Google Custom Search Engine

- Tapir - hosted service that indexes pages on your RSS feed.

- Tipue - self hosted javaScript plugin, well documented, includes options for pinned search results.

- lunr.js - javaScript library.

- phinde - self hosted php and elasticsearch based search engine

See also http://indieweb.org/search#Software

Subscription (aka paid) Services:

- Google Site Search

- Swiftype - offers a free plan for personal sites/blogs.

- Algolia

- Amazon Cloud Search

Problem

Basically I've got an old static html site ( http://www.brownwatson.co.uk/brochure/page1.html ) I need to add a search box to it to search a folder called /brochure within that folder is html documents and images etc I need the search to find ISBN numbers, Book Reference Numbers, Titles etc.. There's no database the hosting provider has got php I was trying to create something like this: ``` <div id="contentsearch"> <form id="searchForm" name="searchForm" method="post" action="search.php"> <input name="search" type="text" value="search" maxlength="200" /> <input name="submit" type="submit" value="Search" /> </form> <?php $dir = "/brochure/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file == $_POST['search']){ echo('<a href="'.$dir . $file.'">'. $file .'</a>'."\n"); } } closedir($dh); } } ?> </div> ``` I know, I know this is pretty bad and doesn't work any ideas? I haven't created anything like this in years, and have pretty much just taken bits of code and stuck it together!

Original source