McShelby / hugo-theme-relearn

A theme for Hugo designed for documentation
https://mcshelby.github.io/hugo-theme-relearn/
MIT License
409 stars 183 forks source link

Loading searchindexurl doesn't work with actual BaseURLs that have folders like https://abc.aiprm.com/AIPRM-XYZ/ #940

Open christophcemper opened 2 hours ago

christophcemper commented 2 hours ago

Great job with the theme, thanks!

We needed to remove the artifical prefixing of the language code to make this work in search.html to even use the default _relearn_searchindex.js from the assets folder of the theme

BaseURL is https://abc.aiprm.com/AIPRM-XYZ/ Site is multilingual However the static files are only deployed 1 time, to https://abc.aiprm.com/AIPRM-XYZ/_relearn_searchindex.js The special case that someone deploys the same static files to language-prefixed folders cannot be default.

Also it was constructed wrong, as it ended up in https://abc.aiprm.com/en/_relearn_searchindex.js which doesn't even sit in the same home folder/vserver on the http and the same for all other languages.

In a 2nd line of code we had the relLangURL, which again implies the special case being default - assets in language folders and enforces the current language prefixed

here's the diff and changed file attached, not sure how to commit/add directly to repo

diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 3c5acda17c..9b1c143f48 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -11,14 +11,14 @@ {{- warnf "UNSUPPORTED usage of 'searchpage' output format found, remove it from your config; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/7/#7-0-0" }} {{- end }} {{- if not .Site.Params.disableSearchIndex }}

search.html.zip

If there's a use case where people have separate static asset folders, then that would be a separate mode to implement imho, but the default theme should work out-of-the-box imho.

Hope this helps.

christophcemper commented 2 hours ago

Ok found the PR feature :)

McShelby commented 2 hours ago

Thanks for the detailed bug report. Just for completeness, can you please post your hugo.toml. This helps in recreating a failing test before starting to fix and break for other configurations.