add FAQ for Search not working

This commit is contained in:
Aditya Telange 2021-03-28 10:27:22 +05:30
parent e7550feb5f
commit ee584bf188
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77

View File

@ -290,6 +290,24 @@ ex.
---
## Search not working ?
If you are using a CDN to server assets from a different domain, search would break
Why? Take a look at [fastsearch.js#L35](https://github.com/adityatelange/hugo-PaperMod/blob/fb4988cfb6d0d6e4e489f17d89f0fa618def3396/assets/js/fastsearch.js#L35).
We fetch the `index.json` (where the search function looks for the keywords typed) one level up of the website `search.min.js` is hosted on.
We have used this insted of assigning `baseURL` so as to work with multilingual websites ex. `example.com/fr/` and websites being placed under a subdirectory ex. `example.com/blog/`.
To fix for _single_ language websites hosting assets from CDN, this you may [override](#override-theme-template) [fastsearch.js#L35](https://github.com/adityatelange/hugo-PaperMod/blob/fb4988cfb6d0d6e4e489f17d89f0fa618def3396/assets/js/fastsearch.js#L35) and placing appropriate URL as in
```js
xhr.open("GET", "https://example.com/index.json");
```
---
## References
- [Override a Hugo theme](https://zwbetz.com/override-a-hugo-theme/)