This is not a standalone theme. This is a Hugo theme component.
To use this component,
-
Add this to your site's TOML config file:
[module] [[module.imports]] path = "github.com/kaushalmodi/hugo-search-fuse-js"
-
Run
hugo mod tidy
in your main site directory. The main site repo needs to be a Hugo module as well (it needs to have its owngo.mod
). To make it one, runhugo mod init <your site url or any unique string>
in your site repo before you do this step. -
Create
content/search.md
withlayout
parameter set to "search", andoutput
parameter set to["html", "json"]
. The content or body of thissearch.md
is not used by thesearch.html
template which is part of this theme component.Here is an example
search.md
:+++ title = "Search" layout = "search" outputs = ["html", "json"] [sitemap] priority = 0.1 +++
You need to install the latest version of Go from
https://go.dev/doc/install because this theme component requires
hugo mod ..
commands
to work.
This update on switch to using Hugo Modules was last tested with Hugo v0.92.0.
- Your main theme must be structured using base template and blocks, and
- The
base
template needs to definemain
andfooter
blocks (shown in that previous link).
If the main theme does not meet these requirements, you will need to edit the
search.html
partial to make search work. You can find it in layouts/_default/search.html
in this component.
You have two options:
- Edit the
search.html
to make it fit your theme. - Upgrade the theme to use the new "base template and blocks" approach.
It's very easy to add those blocks without breaking your existing theme.
To add the main
block, add this to your baseof.html
at the
appropriate place:
{{ block "main" . }}{{ end }}
And similarly add the below if the footer
block is missing:
{{ block "footer" . }}{{ end }}
For an example, see the baseof.html
snippet in Hugo
docs.
- Search functionality by fuse.js.
- Keyword highlighting by mark.js.
- Initial Hugo implementation by @eddiewebb in this gist.
- Hugo theme component packaging by @kaushalmodi.
- jQuery removal and IE polyfill integration by @lpar.
- IE compatibility polyfills: