<Marc Qualie/>

GoStatic Search API Beta

One of the huge down-sides of having a static site is the in-ability to do search. It's not impossible, but the solutions out there are no where near as good as their dynamic CMS competitors. Searching a static site is hard. GoStatic now supports the ability to search your entire project without having to do any extra configuration on your end.

There are many solutions out there and I'm going to cover each one of them in a bit of detail and explain why GoStatic's solution out weighs them and why it is a great choice for your next search-enabled static project.

Solution 1: Client Side Search

This is the approach I used to use for this blog before I switched to GoStatic. I love this implementation because it doesn't require any extra build configuration and it's always up to date with your content. While this solution is cheap, easy and fast to implement it does come with a few downsides. First of all, all of your content has to be bundled into a js file which is either included in your main page, or loaded in via XHR when you land on the search page. This does allow for instant search result but adds weight to every page load when there are a lot of posts and the build/deploy process is slowed down as a consequence. The other main downside is this approach is proprietary to whatever static CMS you are using due to the fact it is part of the build process and makes it a pain to switch provider.

Solution 2: Third Party Provider

Using a third party provider can be a nice solution for a lot of projects because it moves all of the complexity to another service and you never have to worry about maintaining your dependencies or libraries. The reason I didn't use this solution compared to the client side implementation is simply cost. These services normally charge on a per query basis which can become quite expensive if you have a lot of traffic on your site. You are also adding one more dependency and cost to your stack which is the problem GoStatic aims to solve in the first place. The one big advantage I see to this solution is that you are not tied to one single provider as the indexing and storage is handled entirely by the third party, normally via a web scraper that indexes whenever you update your content via a web hook.

Solution 3: GoStatic

GoStatic combines the best of both of these solutions by allowing you to shift the complexity of the indexing to a third party while keeping the cost benefits of your own client side implementation. If you are already hosting your site on GoStatic then search is included by default as part of your package. You can either use the provided SDK (coming soon) or roll your own using the REST API. Since posts are indexed during site compilation, the index is always up to date with your latest content unlike a lot of providers.

In conclusion I personally think a third party solution is the way to go, whether that be GoStatic or another provider. Search is a core feature of most sites and it's something that has to be fast, accurate and flexible which just isn't possible on a static site when compiled at build time. You can request a free BETA invite to GoStatic in the comments below.

If you have any questions about this post, or anything else, you can get in touch on Twitter or browse my code on Github.