Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does search requires build? #123

Closed
Anthony-Gaudino opened this issue Nov 25, 2021 · 10 comments
Closed

Does search requires build? #123

Anthony-Gaudino opened this issue Nov 25, 2021 · 10 comments

Comments

@Anthony-Gaudino
Copy link

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?

@weareoutman
Copy link
Member

Currently, yes, it requires build.

@RogalaPiotr
Copy link

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!

@RogalaPiotr
Copy link

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:

  1. npm run build
  • after this command you should have new folder "build" in your app
  1. 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.

@TysonMN
Copy link

TysonMN commented Jan 25, 2022

I'm trying by those commands without effects:

  • npm run build
  • yarn run build

The command you were looking for is yarn build.

@SebastianSchuetze
Copy link

@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.

@james-s-w-clark
Copy link

  • yarn build to build the static site
  • yarn run serve to serve the static site
    I have the searchbar working locally with this.

@kdb13
Copy link

kdb13 commented Jun 22, 2023

In my case the search is showing no results. I followed the steps below:

  1. DEBUG=search-local:* npm run build
  2. 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.

@techbridgedev
Copy link

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.

@weareoutman
Copy link
Member

Closing this, see discussions in facebook/docusaurus#8283

@dakshika
Copy link

In my case the search is showing no results. I followed the steps below:

  1. DEBUG=search-local:* npm run build
  2. 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.

having same issue with my setup too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants