Error while using search module #2
-
|
I tried to use the search module. But I encountered some error. What I have tried?I tried following instructions at https://hugomods.com/en/docs/search/. I don't want a single search page, so I followed the instructions accordingly. What's the error?I guess the module is not getting imported? My hugo.toml: [module]
[[modules.imports]]
path = "github.com/hugomods/search"
[outputs]
home = ["HTML", "RSS", 'SearchIndex']I have initialized my repo as a hugo module by running My <!doctype html>
<html lang="en">
{{ partial "head.html" . }}
{{ if .IsHome }}
<body class="home-template notransition"
data-theme="{{ .Site.Params.defaultColorScheme | default "auto" }}" data-nav="sticky">
{{ else }}
<body class="notransition"
data-theme="{{ .Site.Params.defaultColorScheme | default "auto" }}" data-nav="sticky">
{{ end }}
{{ partial "header-logos.html" . }}
{{ partial "nav.html" . }}
<div class="site-wrap">
{{ if .IsHome }}
{{ partial "home-cover.html" . }}
{{ end }}
<div class="main">
{{ block "main" . }}{{ end }}
</div>
{{ partial "email-subs.html" . }}
{{ partial "footer.html" . }}
</div>
<script src="{{ "js/main.js" | relURL }}"></script>
{{ $js := resources.Get "main.ts" | js.Build }}
{{ $searchJS := partial "search/assets/js-resource" . }}
{{ $js = slice $js $searchJS | resources.Concat "js/main.js" }}
<script src="{{ $js.RelPermalink }}" defer></script>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hi, I think there is a typo on |
Beta Was this translation helpful? Give feedback.
-
Yes, PostCSS CLI is required for building the search styles, since it's not embeded into Hugo releases (if I remember correctly), see https://github.com/hugomods/search/blob/2f052c6c49cc794b2a74bca42def1c06648810a8/layouts/partials/search/assets/css-resource.html#L11C1-L11C1. |
Beta Was this translation helpful? Give feedback.
Do you have a public repo for reproducing?
According to the logs, it maybe caused by the
{{ $js := resources.Get "main.ts" | js.Build }}.The
main.tsis the JS source of the theme/site, when there isn'tassets/main.tsin the theme/site, then it fails, so if you're not using Hugo pipes to build the theme's JS, please use the following instead.{{ partial "search/assets/js" . }}The code snippet you used is intended to combine the search JS and theme/site JS into one bundle/file to reduce HTTP requests.
I must admit that the docs are unclear, will update the docs later, sorry for the inconvenient.
Btw, similarly, the
main.scssis the theme/site's styles file.