Search Overview
TinaCMS provides built-in search functionality for content. This is useful for allowing editors to quickly finding content in a site. TinaCloud's content search is powered by Fergus McDowall's search-index library.
Search is not currently supported in self-hosted TinaCMS.
Configuration
To enable search functionality, you will need to populate the search field in your TinaCMS configuration. The only required element of the search configuration when using TinaCloud search is the search.tina.indexerToken field. This can be obtained from the TinaCloud dashboard for the project.
Definition
TinaCloud search token
Optional array of string stopword languages. See the stopword GitHub repository for a full list of supported languages.
['eng'].Enable or disable fuzzy search globally.
true.Maximum edit distance for fuzzy matching (0-10). Higher values find more distant matches but may return less relevant results.
2.Minimum similarity score (0-1) required for a match. Higher values return more precise matches.
0.6.Maximum number of similar terms to consider per search word (1-100).
10.Allow character transpositions (e.g., "teh" → "the") using Damerau-Levenshtein algorithm.
true.Used by the indexing process to determine the number of documents to index per request.
100.For variable length text fields, this controls how much of the text is considered when indexing. A higher value will increase the indexing time and size of the search index.
100.All properties marked as REQUIRED must be specified for the field to work properly.
Building the search index
Development
When search is configured and a site is running locally with the dev command, content will be automatically indexed at startup. Any changes to local content will also trigger updates to the (local) search index.
Production
When search is configured and a site is being built for production using the build command, the search index will be automatically created and uploaded to TinaCloud. Each Git branch for your site has a separate search index.
Note that the search index is "live" once the site is built, so any newly added or removed content may be reflected in the search index before the site has been deployed. Building the search index can be skipped by passing the --skip-search-index cli option to the build command. Then the search-index command can be run separately once the site deployment completes.
Customizing search indexing
Excluding fields
By default, all collection field types (except image) are including in the search index. You can improve discoverability of content by controlling which fields are included in the search index. This is done by setting the optional searchable property on fields in the collection schema. For example, to disable indexing for an author field, use something like:
Limiting text fields
By default, only the first 100 characters of a text field are used when building the search index. This can be adjusted globally in the search configuration (see above), but can also be done on a per field basis like so:
Fuzzy Search
TinaCMS includes built-in fuzzy search capabilities that help users find content even when they make typos or spelling mistakes. Fuzzy search is enabled by default, so your search will automatically handle common misspellings without any additional configuration.
Fuzzy search was released in tinacms@3.3.0 and @tinacms/cli@2.1.0. No config changes are needed to get the benefits of the new search — just update your packages!
How Fuzzy Search Works
Fuzzy search finds terms in your content that are "similar" to what the user typed, even if they don't match exactly. TinaCMS uses the Damerau-Levenshtein distance algorithm, which measures similarity by counting the minimum number of single-character edits needed to transform one word into another.
Supported edit operations:
When a user searches, each word in their query is expanded to include similar terms from your indexed content. For example, searching "Raect tutrial" would also match documents containing "React tutorial".
Configuration
Fuzzy search works out of the box with sensible defaults. You can customize its behavior by adding fuzzyOptions to your search configuration:
Examples
Here are examples of typos that fuzzy search will catch with the default settings:
Disabling Fuzzy Search
If you prefer exact matching only, you can disable fuzzy search:
Performance Tips
Fuzzy search includes automatic caching for repeated queries. If you need to optimize performance further, consider these adjustments:
Example configuration for stricter, faster matching:
Troubleshooting
Alternative Search Providers
Currently only TinaCloud's search API is supported but we plan to provide alternative providers in the near future, as well as documentation for implementing custom search providers. If you'd like support for a specific search provider, let us know.