PageFind
Table of Contents
Pagefind
Install PageFind: https://pagefind.app/docs/installation/
Don’t have to install it. Just use the npx version of the command.
How to show the search box on the UI pages for Hugo themes?
This is to use the search functionality in web pages.
The process slightly varies based on the theme that is being used.
Include the function from “Pagefind” documentation in the appropriate html file in the theme.
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
ananke theme
In the file project-root/themes/ananke/layouts/partials/site-navigation.html
anatole theme
project-root/themes/anatole/layouts/partials/navbar.html
mainroad theme
project-root/themes/mainroad/layouts/partials/menu.html
archie theme
project-root/themes/archie/layouts/partials/head.html