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

Algolia Search on Jekyll Sites

by Tim Carry (tim@algolia.com)

Who am I?

Tim Carry

@pixelastic

What is Jekyll?

It's a static website generator.
It takes markdown and templates files and outputs HTML.

jekyll build

Markdown
HTML
Markdown
Jekyll

What is Algolia?

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

Algolia in 3 steps

  1. Syncing data
  2. Ranking and Relevance
  3. Front-end Search
3 easy steps 3 easy steps 3 easy steps

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. Parse generated HTML
  2. Split by paragraph
  3. Push 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

Coming soon…

Questions?

2 months free with voucher PARISRB

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