Summary

This website uses the Hugo PaperMod theme. You can find few debugging and research notes below.

Debugging

When setting up the website, we had a few bugs with PaperMod’s search functionality.

  • There is a small wiki section on search.
  • If you use languages in your config.yaml (or hugo.yaml), make sure you name the search file content/search.en.md.
  • Related post

Search calibration and algorithm

Current parameters for search:

fuseOpts:
    isCaseSensitive: false
    includeScore: false
    shouldSort: true
    location: 0
    distance: 1000
    threshold: 0.6
    minMatchCharLength: 0
    keys: ["title", "permalink", "summary", "content"]
  • PaperMod uses fuse.js for its fuzzy search.
  • Options to calibrate are described here.
  • Read about the fuse.js scoring theory here.
  • Under the hood, fuse.js uses the Bitap algorithm.

Weights

PaperMod explains it here. Weight is used to control the positioning of entries. The Hugo Wiki:

A non-zero integer indicating the entry’s position relative the root of the menu, or to its parent for a child entry. Lighter entries float to the top, while heavier entries sink to the bottom.

For example, we sort our top right menu as follows:

buttons:
  - name: Posts
    url: posts
    weight: 10
  - name: Search
    url: search
    weight: 20
  - name: Tags
    url: tags
    weight: 30
  - name: Archives
    url: archives
    weight: 40

Page header template

Each post has a dedicated section for metadata. Here is the one for this post:

---
author: ["DefJM"]
title: "Hugo PaperMod setup"
date: 2024-01-23
draft: false
tags: ["papermod", "hugo", "website", "fuzzy_search"]
cover:
    image: images/papermod-cover.png
    hiddenInList: true
---