Create site search shows multiple ways to implement a search in a website.

But what if the site is not dynamic, meaning it’s all containing static HTML pages, no database used in the site etc? Here is an easy solution for this.

What are Static Websites?

The content of the webpage won’t change until somebody manually changes it. Created without server-side logic.

This is generally preferred when people start in the initial days of their website.

Static websites are generally faster than dynamic websites as there is no server-side computation involved.

Content Management System sites(CMS) are bound with a database, server-side scripting etc and have search functionality enabled by default. But for static websites, there is no support of server-side logic to handle a search query of the user and its the biggest drawback. Of course, there will be tags, categories but how to handle free text queries of users?

1. Integrating remote search providers:

Create Site Search is one of the easiest way to create a search for your website.

You need to signup to the search service provider and they will catalog search for you. Then you add search to your pages and your site users will start using this tool.

You need to wait till the search-bots will explore links on your site and will index your site.

Expertrec is one of the easiest search providers along with Google, Yahoo, MSN, Bing etc.

Being a static website, there might not be proper linking between pages so its necessary to have a proper sitemap with link mentioned in robots.txt . More on sitemap and how to generate it is discussed here.

2. Search implementation on the client side:

This is an easy solution but client browser has to support javascript to accomplish this.

The browser is going to fetch all the pages(static) and going to search on them for every query from the user.

There are search libraries for this such as fuse.js . But this is going to be limited to search on specific fields for every page – ex. title, tags, categories, links etc.

Also, it is limited to the certain pages only( Expecting this approach to work with 1K or more number of pages will make user experience worst).

 

In summary, implementing site search for static websites is easy. Instead of implementing it in client side, it is recommended to use already existing search providers such as Expertrec, Google, Bing, Yahoo etc.

You need to wait till search-bots index the site and results will be rendered on your site but search catalog will be built at the search providers index.

It’s important to mention all the URLs in sitemap as search-bots are going to find pages using it.

Create search for static website @ 9USD per month

Happy Searching.