Change Language

Search

Hguinav has search built-in. This is a quick overview on how to create your search.

Configuration

These configurations apply on params object of the config. See search configuration for more information and supported configuration options.

Search Formats

lunr

This uses JSON file to produce the search content and thus slower and not available for very large content.

Setup details for lunr format

Setup for search page generation (only for lunr format)

First, remember the following:

Create a folder called search in the content directory, and add _index.md with the following content:

---
title: Search
placeholder: Search across the site
outputs:
- html
- rss
- json
---

You can also remove the RSS if you don't want to generate RSS for this section, which is usually not needed for RSS to be generated.

You can create the same search for other languages with the _index.languageCode.md prefix.

pagefind

This format is default used in this theme, and is best for large content. However, this cannot be used in preview, such as hugo serve. This format requires to have Python installed, and pagefind[extended] package.

Setup Pagefind

Setup Pagefind

Do the following to get up and run Pagefind. We'll asume you have Python installed:

  1. Install Pagefind extended version. You can do this by this command. pip install pagefind[extended]
  2. Set the search format in the search object.
  3. Build the site. hugo
  4. Generate the search index. Make sure to replace outputdir with the directory where your built files live. python -m pagefind --site outputdir

That's it!

You might also like

This site is last updated ago