docusaurus/docs/guides-search.md
Tim Carry 5afc0b0a1c Simplify DocSearch documentation (#624)
* Simplifying DocSearch documentation

I slightly rewrote the DocSearch documentation. The main three points are:

- I explained a bit more how DocSearch works (trying to explain that it's an external service that requires the website to be online)
- I removed mentions to the _search_ API key as in that case, it's always a _search_ (as opposed to _admin_) API key that is used
- I removed the part about faceting on the version. I thought it was confusing as without a specific UI to display the faceting, this won't do much. To use it properly, one will need to dig more into layouts. I might submit a PR about that later, but as it was today I think it would just create confusing rather that adding value

Hope that helps :)

* Make links URLs inline
2018-05-02 08:27:17 -07:00

1.8 KiB

id title
search Enabling Search

Docusaurus supports search using Algolia DocSearch. Once your website is online, you can submit it to DocSearch. Algolia will then send you credentials you can add to your siteConfig.js.

DocSearch works by crawling the content of your website every 24 hours and putting all the content in an Algolia index. This content is then queried directly from your front-end using the Algolia API. Note that your website need to be publicly available for this to work (ie. not behind a firewall). This service is free.

Enter your API key and index name (sent by Algolia) into siteConfig.js in the algolia section to enable search for your site.

const siteConfig = {
  ...
  algolia: {
    apiKey: 'my-api-key',
    indexName: 'my-index-name',
    algoliaOptions: {} // Optional, if provided by Algolia
  },
  ...
};

Algolia might provide you with extra search options. If so, you should add them to the algoliaOptions object.

By default, the search bar will be the rightmost element in the top navigation bar.

If you want to change the default location, add the searchBar flag in the headerLinks field of siteConfig.js in your desired location. For example, you may want the search bar between your internal and external links.

const siteConfig = {
  ...
  headerLinks: [
    {...}
    {...}
    { search: true }
    {...}
    {...}
  ],
  ...
};

To disable the search bar, comment out (recommended) or delete the algolia section in the siteConfig.js file.

Also, if you have customized the location of the search bar in headerLinks, set search: false.