This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 730
Feature Request: Add a search bar or a tutorial on how to add one. #465
Comments
Hi @AribYadi, because Hugo produces a static website, dynamic functionality like search would have to generally have to be provided by an external provider like Elasticsearch, Solr, or Algolia. There are some client-side search options you can look at: https://github.com/nextapps-de/flexsearch |
I wouldn't say I love the content matching algorithm, but this was a simple solution that looks quite nice with this theme. Add > hugo mod get github.com/hugomods/search@latest Add to # Navbar menu item
[[languages.en.menu.main]]
identifier = "search"
name = "Search (^K)"
url = "/search"
# Search mod config
[params.search]
min_match_char_length = 3
ignore_location = true
threshold = 0
distance = 0
index_content = true
index_all_pages = false
expand_results_meta = true
# Output search index for modal and search page
[outputs]
home = ['HTML', 'Search', 'SearchIndex']
# Add module
[[module.imports]]
path = 'github.com/hugomods/search' Add JS/CSS to {{ partial "search/assets/js" . }}
{{ partial "search/assets/css" . }}
<!-- NOTE: Styling is configured for the green theme -->
<style>
:root {
--search-primary: rgb(120, 226, 160);
--search-color: rgba(120, 226, 160);
--search-bg: rgb(31, 34, 42);
--search-result-bg: rgb(31, 34, 42);
--search-border-color: rgb(120, 226, 160);
}
</style> Create a search page (for when not using the modal via keyboard shortcut) by adding {{ define "main" }}
<div class="search-container"></div>
{{ end }} If this is helpful, I can create a doc. And if anyone has better search algorithms or parameters, let me know! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I need a search bar or a search page on my blog. If you don't want to add one, can you make a tutorial on how to add one?
The text was updated successfully, but these errors were encountered: