https://github.com/algolia/algoliasearch-jekyll

Algolia Search on Jekyll Sites

by Tim Carry (tim@algolia.com)

What is Algolia?

  • Hosted search API
  • Fast and relevant
  • Instant search UI
Autocomplete

Plugin integration

1. Editing Gemfile

group :jekyll_plugins do
  gem 'algoliasearch-jekyll'
end

2. Editing _config.yml

algolia:
  application_id: 'D34DB33F42'
  index_name: 'blog'

3. Running the command

$ ALGOLIA_API_KEY=XXXX jekyll algolia push

Indexing 1000 items
Indexing 253 items
Indexing of 1253 items in blog done.

How it works

  1. Parses generated HTML
  2. Split by paragraph
  3. Pushes to Algolia
{
  "content": "<p>Simple, blog-aware, static site generator.</p>",
  "title": "Testing several Jekyll versions",
  "url": "/2016/01/06/testing-several-jekyll-versions",
  "posted_at": 1404770400,
  "tags": ["jekyll", "test"],
  "custom_front_matter": "Custom value"
}

Configuration

algolia:
  record_css_selector: 'p,.custom-selector,blockquote'
  excluded_files:
    - index.html
  settings:
    highlightPostTag: '</mark>'
    highlightPreTag: '<mark>'
class AlgoliaSearchRecordExtractor
  def custom_hook_each(item, node)
    # Enrich the record with your own data
    item['custom_attribute'] = 'foo bar'
    item
  end
  def custom_hook_all(items)
    items.filter do |item|
      # Keep only some records if you want
    end
  end
end

Front-end

Fully automated

  • Host it on GitHub pages
  • Run a build on Travis
  • Re-index on each push
  • 10.000 records free

Want more?

2 months free with voucher JEKYLLCONF2016

Redeem on https://www.algolia.com/redeem/