Local Search
Local search no need any external 3rd-party services and can be extra indexed by search engines. That search method recommended for most users.
Install hexo-generator-searchdb
by run following command in site root dir:
$ npm install hexo-generator-searchdb --save
Edit site config file and add following content:
1 | search: |
Edit theme config file to enable Local Search:
1 | # Local search |
Algolia Search
NexT provides Algolia search plugin for index your hexo website content. What you should note here is that only turn on enable
of algolia_search
in theme config file cannot let you use the algolia search correctly, you need to install corresponding Hexo Algolia plugin to seach your website with Algolia. Follow the steps described below to complete the installation of Algolia search.
Register at Algolia, you can log in directly using GitHub or Google Account. Upon Customer’s initial sign-up for an Account, Customer will have a free, fourteen (14) day evaluation period (the «Evaluation Period») for the Algolia Services commencing on the Effective Date, subject to the limitations on Algolia’s website. After that, Algolia offers a free, branded version for up to 10k records and 100k operations per month.
If a tutorial pops up, you can skip it. Go straight to create an
Index
which will be used later.Go to the
API Keys
page and find your credentials. You will need theApplication ID
and theSearch-only API key
in the following sections. TheAdmin API key
need to keep confidential. Never store your Admin API Key asapiKey
in theme config file: it would give full control of your Algolia index to others and you don’t want to face the consequences.In the
API Keys
page, click theALL API KEYS
and theedit
option in the created APIKEY to activate a pop-up box where you can setup authorizations and restrictions with a great level of precision. CheckAdd records
,Delete records
,List indices
,Delete index
features in ACL permissions that will be allowed for the given API key. And then click theUpdate
button.
In your site config file, add the following configuration and replace the applicationID
& apiKey
& indexName
with corresponding fields obtained at Algolia.
1 | algolia: |
Algolia requires users to upload their search index data either manually or via provided APIs. Install and configure Hexo Algolia in your Hexo directory. This plugin will index your site and upload selected data to Algolia.
1
2$ cd hexo
$ npm install –save hexo-algoliaRun the following command to upload index data, keep a weather eye out the output of the command.
1
2
3
4$ export HEXO_ALGOLIA_INDEXING_KEY=Search-Only API key # Use Git Bash
# set HEXO_ALGOLIA_INDEXING_KEY=Search-Only API key # Use Windows command line
$ hexo clean
$ hexo algoliaChange dir to NexT directory, and install module to
source/lib
directory.1
2$ cd themes/next
$ git clone https://github.com/theme-next/theme-next-algolia-instant-search source/lib/algolia-instant-search
If you want to use the CDN instead of clone this repo, then need to set vendors in theme config file:
next/_config.yml 1
2
3
4
5
6
7vendors:
…
# Internal version: 1
# https://www.algolia.com
algolia_instant_js: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.js
algolia_instant_css: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.css
…
In theme config file, turn on enable
of algolia_search
. At the same time, you need to turn off other search plugins like Local Search. You can also adjust the text in labels
according to your needs.
1 | # Algolia Search |
Known Issues
- The latest version of the Hexo-Algolia plugin removes the content indexing feature, given Algolia’s free account limitation.
- The Hexo-Algoliasearch plugin provides content indexing functionality, but requires the replacement of keywords in the NexT theme. The same problem exists with
Record Too Big
for Algolia’s free account.- Replace all
applicationID
insource/js/src/algolia-search.js
withappId
- Replace all
applicationID
inlayout/_partials/head/head.swig
withappId
- Replace all
Swiftype Search
Go to Swiftype Sign Page to sign up.
After signing up create a new search engine and follow instructions.
After creating choose Integrate
→ Install Search
in the menu to customize with instructions. Then click Active
button finally.
Back to INSTALL CODE
and copy your swiftype_key
.
Edit theme config file and fill section swiftype_key
with value of your key gets:
1 | # Swiftype Search API Key |