HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.12k stars 2.89k forks source link

Stardard search results are empty when baseURL has a path #2985

Closed danikiev closed 1 year ago

danikiev commented 1 year ago

Preliminary Checks

Description

In starter-hugo-academic if I change baseURL in config.yaml to https://example.com/test/, the default wowchemy search produces empty results.

Earlier it was working (wowchemy 4.8)

Reproduction Link

https://github.com/wowchemy/starter-hugo-academic

Steps to Reproduce

  1. Clone the starter-hugo-academic:
    git clone https://github.com/wowchemy/starter-hugo-academic.git
  2. Change baseURL to an address with path, e.g. change line 7 of the file config/_default/config.yaml to baseURL: 'https://example.com/test/'
  3. Serve the website with hugo server
  4. Search for 'welcome'

Expected Result

2 results

Actual Result

Search results are empty

What Hugo Module versions does your site use?

module github.com/wowchemy/starter-hugo-academic

go 1.15

require ( github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify v1.0.0 // indirect github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify-cms v1.0.0 // indirect github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-reveal v1.0.0 // indirect github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/v5 v5.8.1 )

What operating system(s) are you seeing the problem on?

Windows, Linux

What browser(s) are you seeing the problem on?

Chrome, Firefox

Which Wowchemy template are you using?

starter-hugo-academic

What version of Hugo are you using?

hugo extended v0.115.4

valette commented 1 year ago

it seems that index.json is not loaded (404 error) due to its URL set to the root adress of baseURL, without the complete path.

danikiev commented 1 year ago

I don't see any path without /test/ in index.json.

And also it loads if I enter http://localhost:1313/test/index.json

valette commented 1 year ago

I don't see any path without /test/ in index.json.

And also it loads if I enter http://localhost:1313/test/index.json

yes, the issue is not the content of index.json. And index.json is present at its correct URL. The problem comes from trying to load index.json with incomplete URL (without the "/test/" subpath). Most probably the issue comes from here: https://github.com/wowchemy/wowchemy-hugo-themes/blob/f47bd809f7688507f4144f9592da038d56542ef3/modules/wowchemy/layouts/partials/site_js.html?plain=1#L115

danikiev commented 1 year ago

Oh, you are right. Changing it manually there to "/test/index.json" fixes the search. Not sure how to provide the correct path from a variable...