schnerring / hugo-theme-gruvbox

A retro-looking Hugo theme inspired by gruvbox. The pastel colors are high contrast, easily distinguishable, pleasing to the eye, and feature light and dark color palettes.
MIT License
196 stars 50 forks source link

Question about search #191

Closed dougforpres closed 1 year ago

dougforpres commented 1 year ago

Hi, I just ported my small blog/site from Wordpress to a github site using hugo/gruvbox.

Firstly, very cool - I like it a lot!

My question related to the search option - it only seems to search/index blog/post items. Ideally I'd like it to search all my content.

I checked your personal site and it seems to behave the same.

Wondering if this line of code is pointing to some config that can be added/tweaked to add extra sections to index? https://github.com/schnerring/hugo-theme-gruvbox/blob/4a4180acb46a27f1a6584af760fefde54b868edd/assets/js/flexsearch.js#L70

Thanks again - your theme is awesome.

schnerring commented 1 year ago

Thanks, I'm glad you like the theme!

The snippet you mentioned is from the Hugo docs.

To list the most relevant pages on the front page or similar, you should use the site.Params.mainSections list instead of comparing section names to hard-coded values like "posts" or "post".

{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}

If the user has not set this configuration parameter in their site configuration, it will default to the section with the most pages.

The user can override the default:

[params]
 mainSections = ['blog', 'docs']

So I think you need to redefine the mainSections variable. The same snippet is used for the index page:

https://github.com/schnerring/hugo-theme-gruvbox/blob/169f63942ba16b6bdd88ea08ca2ce8641cec5b1a/layouts/index.html#L9

Let me know if that helps!

dougforpres commented 1 year ago

Awesome, thank you - I updated the config and it works great.