First, if you’d like to and see this blog entry in its original context, then read my original stackoverflow answer here.
So, according to blogdown authors (Xie et al. 2018), it’s been said before that,
“If you don’t have a website nowadays, you don’t exist” –Carlos Scheidegger.
A quick search online returns blog posts and sites with several variations on this them (e.g. here and here) acknowledging the axiomatic importance of an online presence these days.
Recently, I decided to rewrite my personal academic website, a site that I had based on Wordpress (with only two theme changes!) from 2011 to earlier in 2018, in Bootstrap 4. I will write a separate blog post on how I made the transition, which was a major step towards getting with the times for me, and fortunately not too painful.
The present post is about search engines…
Specifically, while redoing my site, I realized that I would have to find/write code, or install plugins, to customize my site and make it more interactive. One of the first things I realized would not be automatically available to me (as it was in Wordpress themes) was a functional search bar. Thus the search for hopefully easy, client-side search engine code began. During this process, I’ve learned about at least three different classes of options from a development standpoint–outsourced (custom), back-end (requiring a server), and client-side (no server). And I’ve also found several options listed below, which we can divide into paid versus free/open-source options:
1. Paid or Free-trial-with-premium options:
These options are generally limited to a couple of hundred pages and 1000-2000 page views per month, and the free versions will crawl your site on a sparse timetable (e.g. monthly) and provide limited functionality. Paid versions are IMHO very expensive and more appropriate for business/company sites (websites that generate income and have large numbers of visitors). All of these intend to be simple and scalable for the average user, and to solve additional problems other than search (e.g. related to SEO).
2. Free/open source custom search options:
- Solr - an Apache project built on Apache Lucene (requires a server and working with APIs; see system requirements in the documentationhere, specifically here)
- Google Custom Search JSON API - integrates with Custom Search Engine and allows obtaining search results without ads
- Tipue Search, jQuery site search code which is meant to be used with json files built with their Beaty tool
- Elasticlunr.js - full text site search engine written in Javascript (requires working with configuration files and APIs)
My choice
In the end, I decided to start with Google Custom Search free edition (with Google’s ads/promotions at the top of my search results; you can pay to have them remove the advertisements), while using test pages to try out other options. By doing this, I’ve been able to quickly and rather painlessly add custom search bars to the footer of all pages for my website that search only my site and my blog. IMHO, I think the result is very resourceful, easy to find on page (obvious to reader), and does not interfere with my nice permanent or sticky top-navbar designs.
My next step is that I am planning to test elasticlunr.js to provide a fully client-side search option. I would love to hear from others who have implemented elasticlunr about their experiences, or from anyone who has encountered a better client-side option.
Good luck!
~J
References
Xie Y, Thomas A, Hill AP (2018). Blogdown: creating websites with R markdown. CRC Press. Available at: https://bookdown.org/yihui/blogdown/.