Home > Designing, Others > Searching the Jamstack

Searching the Jamstack

January 22nd, 2020 Leave a comment Go to comments

Here’s Raymon Camden on adding site search functionality to a site that is statically hosted. A classic trick! Just shoot ’em to Google and scope the results to your site:

<form action="https://www.google.com/search" method="get">
    <input type="search" name="q" value="site:https://www.raymondcamden.com " autofocus size="50">
    <input type="submit" value="Search">
</form>

I’d probably use JavaScript to inject that site: stuff before sending them over just so the search field doesn’t have that weird prefilled stuff in there, which might be off-putting. We covered that here.

Raymond then gets into Google Custom Search Engines, which is their product to provide scoped search on your own site. It’s desirable because it’s Google’s search for your own site. Whatever you might think of Google, they have great search results. That’s the thing. Even if you aren’t a Jamstack site and can freely use your own server to query content on your site, chances are your search results aren’t as good as Google’s.

Say you reach for another search solution… Solr, Lunr, ElasticSearch, Algolia. They are all kinda nice in their own way. The trick is making sure they have enough data for them to return good results, beyond just the content. You’ll never have an entire internet’s worth of backlinks to leverage, but ideally, you can factor in analytics data at the very least.

Direct Link to ArticlePermalink

The post Searching the Jamstack appeared first on CSS-Tricks.

Categories: Designing, Others Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.