I built search with Google Custom Search, but I used the API. I use React as a front end, and the Ghost Content API. I get search results for my domain from Google, and let React parse it. This way I can style the search results as I please. Check it out, https://www.theportlandpour.com/. I’ll post a case study on how I built it next week, but I’m pretty happy with the results.
I was planning to take the same approach for search on my new blog (Google custom search API). You did a great job with yours!
If you would be willing to share a case study or some quick tips that would great! The Google side is easy, but I haven’t explored yet how to get the additional info re. my posts. Are you using the API to get featured images, etc. for the posts / pages that Google returns?
If I can’t find a Search option on a Website, I still use the following within the URL line: “site http://example.tld searchword” (without the quotation marks of course) and after hitting Enter I mostly get what I want.
I know it’s not an elegant Solution but it works. Maybe it would be possible to pack this “Function” into a little Script or behind a Link on the actual Website to make it work like a good Search Function?!
I have built a solution which we use on our blog at ciserro.com/blog, which i have shared as a gist. since we don’t use the frontend of ghost in our webapp (written in React), integrating this with your ghost installation is up to you, but this is a solution anyone can use with self hosting.
@tryghost/content-api to provide a search api for ghost. it also provides an Archive feature which allows you to browse posts by month/year. This module exports 3 functions
archive. search and archive should be setup as express routes, while start should be used to start the search index. you will need to add your ghost credentials in the file before starting it. license is MIT, free to all to use and modify, no attribution needed.
note: you will need to install the dependencies before using. they are
best of luck,
Thanks! I haven’t forgotten about this. I’m finishing the case study this week, but adding some detail. I’ll post the link here when it’s done, but, tldr: set up Google Custom Search, use the REST API to make the request, when you get the response, parse the links for slugs. With an array of slugs, request the content from the Ghost Content API, and display as you see fit. Also, don’t forget to update state with the search page number. IIRC, Google only returns 10 links per request.
Makes sense! Should be reasonably straightforward.
Thank you for your willingness to share more detail when you are able!
I wrote an article on Medium about this. Here’s how I added Google Custom Search to The Portland Pour. @cmckulka https://email@example.com/adding-google-custom-search-to-a-headless-ghost-blog-with-a-react-redux-front-end-b8b79b6dfff7
Great article!! Will definitely be leveraging your lessons learned as I integrate search into my site!
Thank you for offering this to the community.