hugo-toha / toha

A Hugo theme for personal portfolio
https://hugo-toha.github.io
MIT License
1.05k stars 607 forks source link

Search doesn't work on deployed site #508

Closed pvojar closed 1 year ago

pvojar commented 2 years ago

Expected Behavior

Search feature should work on deployed site on Azure Static Web apps.

Current Behavior

Search doesn't return any results on deployed site. On Localhost development works without any problems.

Possible Solution

Steps to Reproduce

deploy toha site to Azure Static Web Apps, try search for post.

On Azure DevOps I found following warning

WARN 2022/01/20 14:31:38 Module "toha" is not compatible with this Hugo version; run "hugo mod graph" for more information. Start building sites …

Screenshots

Browsers Affected

Detailed Description

Edit search.js in toha/statics/js/search.js

old: $.getJSON( window.location.href.split("/search/")[0] + "/index.json", function( data ) {

suggested $.getJSON( "/index.json", function( data ) {

After this edit search started work correctly.

hossainemruz commented 2 years ago

Thanks @pvojar reporting the issue.

MarionMoseby commented 2 years ago

Should I implement this also in my open PR? Seems like an easy fix, and search isn't working on my site either

hossainemruz commented 2 years ago

@MarionMoseby please, send a separate PR.

MarionMoseby commented 2 years ago

@pvojar could you send your site URL's for testing?

MarionMoseby commented 2 years ago

I have been investigating and the issue is not that search is broken (https://www.pablomarcos.me/es/search/?keyword=ecsa works, for instance, if you manually change the keyword) but rather that the "get" form is not appending the ?keyword parameter at the end of the URL. I dont know how to fix this, but the solution is not to change $.getJSON( window.location.href.split("/search/")[0] + "/index.json", function( data ) { into $.getJSON( "/index.json", function( data ) {, as that would make search only work on the main site's language

f-yanez commented 1 year ago

Is there any update here? The search still doesn't work. If you try it on your guide it doesn't show any result: https://toha-guides.netlify.app/search/?keyword=Quickstart

Also, something happens to the UI after using the search box. Notice that the top menu bar gets fixed on the screen and overlaps the search box.

hossainemruz commented 1 year ago

Try pulling main branch. Search should work now properly. Feel free to reopen if you still facing the issue.