Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

lukeocodes/netlify-plugin-algolia-export

Repository files navigation

Netlify Algolia Index Export [Deprecated]

***This package is being deprecated and closed in favour of using the new official Algolia Search Netlify plugin. Please upgrade to this new plugin. ***

Demo

Usage

To install, add the plugin in your netlify.toml or use the Netlify Plugin Directory. There are no required config options, but there are options available.

[[plugins]]
  package = "netlify-plugin-algolia-export"

There are however required environment variables. See the table below. You can read more about setting these in the Build Config: Environment Variables Netlify documentation.

env variable name type required default description
ALGOLIA_APPLICATION_ID String true null Your Algolia application ID
ALGOLIA_ADMIN_KEY String true null Your Algolia Admin (or any index-write enabled) API key
ALGOLIA_INDEX String true null Your Algolia index name

Add algolia config to your deploy environment variables

These values can be found on the Your API Keys page on your Algolia Dashboard.

Algolia Dashboard showing Your API Keys

Options

The available options.

plugins.inputs type required default description
exclude Array false [] An array of paths to exclude from the build. e.g. ['/admin', '/404.html']
textLength Number false 7000 The length the body of the page content will be truncated to. This is due to indexing limitations on community versions of Algolia, which we assume is the default.
stopwords Array false [] Additional stopwords. @see stopword

Examples

Exclude files

Your project probably contains some content files that you don't want your users to search. Pass an array of paths (or regex) to the files you don’t want to be indexed.

[[plugins]]
  package = "netlify-plugin-algolia-export"
    [plugins.inputs]
      exclude = ['''^\/admin.*''', '''^\/search.*''', '/404.html']

Exclude Everything BUT Blog Posts

Advanced Regex Alert! This will exclude all files that DON'T match the regex for URLs like /blog/(year)/(month)/(day)/(slug)/index.html.

[[plugins]]
  package = "netlify-plugin-algolia-export"
    [plugins.inputs]
      exclude = ['''^\/(?!blog\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/(?!index.html)).*''']

Credit

Based on the Netlify Search Index Plugin by swyx for fetching and parsing the content into something we can index, then split from the original version of netlify-plugin-algolia-index.

Contributing

Make pull-requests, but follow code of conduct please.