docusaurus-search-local
docusaurus-search-local copied to clipboard
Does search requires build?
There are other Docusaurus search plugins that only work when the website is built, does this one also requires that the website is built for it to work?
Currently, yes, it requires build.
How to do that? I'm trying by those commands without effects:
- npm run build
- yarn run build
Unfortunately, my search bar is saying: ⚠️ The search index is only available when you run docusaurus build!
OK, I found a solution.
docusaurus-search-local is a fork of docusaurus-search-local there we can find info: "Search does not work in development (i.e., when running yarn start)." >> https://github.com/cmfcmf/docusaurus-search-local
So, if you want run a search, you can:
- npm run build
- after this command you should have new folder "build" in your app
- rebiuld your app with "RUN_MODE=production" - this is necessary to run search properly.
In my example, I am using docusaurus app on image: awesometic/docusaurus. The proper setup to re-run container is like this:
docker run -d --name=docusaurus
-p 80:80
-v /config/dir:/docusaurus
-e TARGET_UID=1000
-e TARGET_GID=1000
-e AUTO_UPDATE=true
-e WEBSITE_NAME="awesometic-docs"
-e TEMPLATE=classic
-e RUN_MODE=production
awesometic/docusaurus
I hope this could help someone in the future.
I'm trying by those commands without effects:
- npm run build
- yarn run build
The command you were looking for is yarn build
.
@Anthony-Gaudino all local search plugins needs to be build.
The sites need to be scanned first and an index being build. This is a given no matter what type of search you have. The only difference between local and online search engines is, that they do this asynchronously. But usually results are not available immediately.
-
yarn build
to build the static site -
yarn run serve
to serve the static site I have the searchbar working locally with this.
In my case the search is showing no results. I followed the steps below:
-
DEBUG=search-local:* npm run build
-
npm run serve
Now, the search bar is also visible and the search-index.json
file is also generated within the build
folder but when I type something it always shows No results.
The DEBUG logs are also not showing any errors.
This issue should be marked closed since the original poster's question has been answered. @KdB13, I have opened a new issue for the empty results bug; feel free to add to it.
Closing this, see discussions in https://github.com/facebook/docusaurus/discussions/8283
In my case the search is showing no results. I followed the steps below:
DEBUG=search-local:* npm run build
npm run serve
Now, the search bar is also visible and the
search-index.json
file is also generated within thebuild
folder but when I type something it always shows No results.The DEBUG logs are also not showing any errors.
having same issue with my setup too