Search on papermod theme

Hi!
I set up a page “Search” on my microblog that I am testing here https://notes.nicfab.it
However, as you can see, if you input any character, the search doesn’t work.
The config.toml contains the following lines:

[[languages.en.menu.main]]
    name = "Search"
    pageref = "page/search"
    weight = 4

[[languages.it.menu.main]]
    name = "Search"
    pageref = "page/search"
    weight = 4

and the following:

[params.fuseOpts]
  isCaseSensitive = false
  shouldSort = true
  location = 0
  distance = 1_000
  threshold = 0.4
  minMatchCharLength = 0
  keys = [ "title", "permalink", "summary", "content" ]

[outputs]
home = [ "HTML", "RSS", "JSON" ]

I created two pages that are respectively under content/english/page and under content/italian/page with the following declaration:

---
title: "Search" # in any language you want
layout: "search" # is necessary
# url: "/archive"
# description: "Description for Search"
summary: "search"
placeholder: "placeholder text in search input box"
---

Where am I wrong?

Is there anyone to help me?

Have you checked out the theme’s documentation on GitHub?

There is a section about search not working over here

Perhaps you would get a more informed answer if you asked directly at the theme repo, so that the people who maintain and contribute to the theme can guide you.

Thank you very much.
I already did what you suggest.
Unfortunately, no answers from the repo.
I already modified the file as suggested by the developer.
Really, I was wondering if did something wrong.

Does search work locally?

Also as per the theme’s documentation Fuse.js is used.

I don’t see that library in the source of the search page

Maybe I’m missing something.

Unfortunately it doesn’t work locally.
What do you think I missed?

I modified the file fastsearch.js as indicated by the developer and I copied it in layout/assets/js because that file is in themes/PaperMod/assets/js
I hope to have done the right thing

It’s hard to say.

You would either need to share the repo for someone to see the full context of your project.

OR

Try setting up search otherwise.

I don’t have the time to debug this for you I’m afraid.

Ok, thank you

Hi!
I solved the arcane!
It seems there is an issue related to the PaperMod configuration of the directory tree (you can see it here: GitHub - adityatelange/hugo-PaperMod at exampleSite).

I was trying to keep organized both pages and posts, creating the following folders:
/content/english/page
/content/english/post
/content/italian/page
/content/italian/post
However, with this setting, the search doesn’t work.

So, I moved all the pages files under /content, distinguishing the Italian ones as filename.it.md.
Thus, I created two folders and precisely /content/post and /content/post_it where I saved the English and the Italian, respectively.
In this way, the search works properly.
Anyway, I hope to find a solution to keep organized the work.

1 Like

You can have more than one content directories in a Hugo project.

In your case, one for the English markdown files and another one for the Italian files.

First you would need to install Go in your system.

On an M1 Mac I use the following:

curl -O https://dl.google.com/go/go1.17.5.darwin-arm64.tar.gz
 
tar -xvf go1.17.5.darwin-arm64.tar.gz

sudo mv go /usr/local
 
go version

rm go1.17.5.darwin-arm64.tar.gz

You can get the latest Go binaries here: Downloads - go.dev
Also you can use a binary for either Intel or Arm (M1) Mac.

Also whenever you need to update the locla Go installation, first make sure to remove the previous version with e.g. sudo rm -rf /usr/local/go


Then you will be able to use Hugo modules ( that are actually Go modules and require a local Go installation).

You can mount several directories as the sources of content.
Have a look at: Configure Modules | Hugo

The following should work.

In the project config enter:

[module]

[[module.mounts]]
source = "english"
target = "content"

[[module.mounts]]
source = "italian"
target = "content"

And then structure the project’s content directories directly under the project root, like so:

<project-root>
├── english
│   └── article.md
└── italian
    └── article.it.md

Afterwards whenever the command hugo is executed both content directories will be merged.

Thank you.
Your solution is for local use only?
Have I to install also Go on my server (Ubuntu 20.0.4) where I deploy the local content?

The answer to your question depends on the server setup.

If you are just publishing to a plain Ubuntu server why not execute hugo locally and use rsync or something similar to upload the static files and keep them in sync?

If you are using Docker or some kind of CI service, then yes you will have to install Go in the build image. For example Netlify’s build images come with Go installed.

I use rsync to deploy the local content on my server.

I tried but the search doesn’t work.
As I wrote, the issue related to the search feature is related to the theme PaperMod that I am using.
Setting the folders by language impede the correct working of the search feature.
If you know a powerful theme instead of PaperMod (I mean that allows the search, social, and some other stuff), please let me know.
Thank you again

There are other ways to setup search.
A simple way without third party libraries is covered here: How To Add Search Feature on Hugo (Without Library) | Nurofsun

Also related topic over here.

P.S. If the Papermod theme is limiting you, here are a few themes that I have tested firsthand.

1 Like

Also here.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.