Skip to content
Configure Azure Search for your Jekyll blog
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
createIndex.js
index.json
package-lock.json
package.json
rebuildIndex.js

README.md

Create and build Azure Search index for your Jekyll blog

Jekyll is a great blogging platform which unfortunately lacks a search capability. Luckily, you can easily push your Jekyll blog's content to an Azure Search instance and use it to provide your readers with a search capability.

Following are two node.js scripts that can help you create and build a search index for your Jekyll blog.

Prerequisites

  1. Clone this repository
  2. Run npm i
  3. In your Azure subscription create a new instance of Azure Search and copy the admin key which you will need to configure the index

Creating the index

The first step is to create the definition of the search index. As a starting point you can use the definition provided in the index.json file but feel free to extend it as necessary using the additional information provided at https://msdn.microsoft.com/en-us/library/azure/dn798941.aspx.

When done run the createIndex.js script:

node createIndex.js --indexFile=./index.json --serviceName=jekyllblog --indexName=posts --adminKey=ABC

Following are the arguments that you have to pass:

  • indexFile - path to the .json file holding the schema of your search index
  • serviceName - name of your Azure Search instance
  • indexName - name of the index to be created
  • adminKey - the admin key to your Azure Search instance

Important: if you want to be able to search on your blog using client-side calls, don't forget to configure CORS for the newly created index on the Azure Management Portal

Rebuilding the index

The next step is to fill the index with the contents of your Jekyll blog so that your readers can search on your blog.

Run the rebuildIndex.js script:

node rebuildIndex.js --postsDir=./_posts --serviceName=jekyllblog --indexName=posts --adminKey=ABC --blogUrl=https://jekyllblog.hosting.io

Following are the arguments that you have to pass:

  • postsDir - path to _posts folder in your Jekyll blog
  • serviceName - name of your Azure Search instance
  • indexName - name of the index to be created
  • adminKey - the admin key to your Azure Search instance
  • blogUrl - the URL of your blog without the trailing slash, eg. https://jekyllblog.hosting.io. This URL is used to prepend your blog posts' slugs

Having completed these steps the last thing left for you to do, is to have the search box on your blog call the Azure Search API. More information about it is available on https://msdn.microsoft.com/en-US/library/azure/dn798927.aspx.

You can’t perform that action at this time.