CaiJimmy / hugo-theme-stack-starter

A quickstart template to create a Hugo blog using hugo-theme-stack
https://demo.stack.jimmycai.com
MIT License
305 stars 105 forks source link

Search page returning no results. #26

Closed Merc-WithaMouse closed 10 months ago

Merc-WithaMouse commented 10 months ago

Allow me to start by giving thanks for providing and maintaining this template.

I started toying with this theme recently and all seemed to be going well. Unfortunately, I've now realised that it appears the search page is not functioning correctly as no results are produced.

I can see that the keyword is entered correctly and is reflected in the page URL, but when trying known keywords, no results are found.

When inspecting via console, I can see the following errors that seem relevant:

[Intervention] Images loaded lazily and replaced with placeholders. Load events are deferred. See https://go.microsoft.com/fwlink/?linkid=2048113

Access to link element resource at 'https://MySite.co.uk/search/index.json' from origin 'https://www.MySite.co.uk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

MySite.co.uk/search/index.json:1 Failed to load resource: net::ERR_FAILED

www.MySite.co.uk/:1 The resource https://MySite.co.uk/search/index.json was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally.

Is this a common issue? If so, what is a possible cause for these types of problems?

image

I am not adverse to rebuilding from scratch if that is the best answer.

CaiJimmy commented 10 months ago

Access to link element resource at 'https://mysite.co.uk/search/index.json' from origin 'https://www.mysite.co.uk/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Set the baseurl field from the config file correctly. If your site runs with a www subdomain, use https://www.mysite.co.uk instead of https://mysite.co.uk.

CaiJimmy commented 10 months ago

Or you can update to the latest version of the theme, which can handle this kind of error.

Merc-WithaMouse commented 10 months ago

First off, thank you for the prompt response.

Secondly, I could have sworn I checked this but apparently not. Embarrassingly, the resolution was to include the www. In the config. My apologies for wasting your time.

Please feel free to close the issue as it was a simple layer 8 problem.

CaiJimmy commented 10 months ago

No worries!