Hugo-Lyra
Hugo is a fantastic static site generator and, like most of them, is not natively capable of implementing a dynamic search engine like we are used to using on more traditional server-side platforms, with more or less advanced query capabilities.
This project aims to solve this problem by integrating the Lyra search engine with Hugo.
It works by parsing the content/\*\*/\*.md files into raw text and using it to generate a Lyra index, which will become a static asset you can publish alongside the other files of Hugo public dist.
This project also offers a client-side javascript library to easily consume the index from your Hugo website; you can see it in action on my personal blog here and here for the implementation. You can jump to the client section for more details.
The parser can parse just Markdown files, and standard front-matter elements, arrays like tags, and categories are imploded and space-separated.
Schema definition:
const hugoDb = create({
schema: {
title: "string",
body: "string",
uri: "string",
meta: {
date: "string",
description: "string",
tags: "string",
categories: "string",
keywords: "string",
summary: "string",
},
},
defaultLanguage: "english",
});
Client side
You need to import the library from the CDN:
<script src=https://unpkg.com/hugo-lyra@latest/dist/browser/hugo-lyra.js></script>
Or better using Hugo Pipes on your base template: