Search Setup
The Feel++ Antora UI provides two search options: Lunr.js for client-side search and Algolia DocSearch for server-based search. The UI automatically detects which search system to use based on your site configuration.
Search functionality is now fully automated through the @feelpp/antora-extensions
package, eliminating the need for manual search index generation.
1. Search Options Overview
Search Type | Best For | Requirements |
---|---|---|
Lunr.js (Default) |
Small to medium sites, self-hosted sites, privacy-focused environments |
@feelpp/antora-extensions package (automatic) |
Algolia DocSearch |
Large sites, sites with complex search requirements, existing Algolia integration |
Algolia account and DocSearch configuration |
2. Lunr.js Client-Side Search
Lunr.js provides full-text search capabilities directly in the browser without requiring any external services. Search index generation is completely automated through the @feelpp/antora-extensions
package.
2.1. Automatic Setup
The UI includes Lunr.js search by default. When you build your site with the Feel++ Antora UI, search functionality is automatically available:
-
The
@feelpp/antora-extensions
package automatically generatessearch-index.json
during site builds -
The UI bundle includes Lunr.js for client-side search functionality
-
No manual configuration or build steps required
2.2. Quick Start for New Sites
To add search to a new Antora site:
2.2.1. 1. Install the Extension
Add the Feel++ Antora extensions to your site configuration:
# site.yml
antora:
extensions:
- '@feelpp/antora-extensions'
2.3. How It Works
The @feelpp/antora-extensions
package includes a Lunr extension that:
-
Automatically generates search index: During the
sitePublished
event, the extension scans all generated HTML files -
Extracts content intelligently: Page titles, content, and URLs are extracted using JSDOM
-
Creates optimized index: Generates a compact
search-index.json
file in your site root -
Supports configuration: Configurable content selectors and indexing options
The extension runs seamlessly during your normal Antora build process - no additional commands needed.
2.4. Configuration Options
You can customize the search index generation by adding configuration to your site.yml
:
# site.yml
antora:
extensions:
- require: '@feelpp/antora-extensions'
lunr_index_generation:
content_selector: 'article.doc .content' # CSS selector for content
exclude_selectors: # Content to exclude
- '.navigation'
- '.page-toc'
- 'pre code'
boost_title: 10 # Title importance multiplier
2.5. Advanced Configuration
For advanced use cases, you can configure multiple content areas or custom extraction logic:
# site.yml
antora:
extensions:
- require: '@feelpp/antora-extensions'
lunr_index_generation:
content_selectors:
- selector: 'h1, h2, h3'
boost: 5
- selector: '.content p'
boost: 1
- selector: '.sidebar'
boost: 0.5
min_content_length: 10 # Minimum content length to index
max_content_length: 1000 # Maximum content length per document
2.6. Search UI Features
The Lunr.js implementation provides:
-
Real-time search: Results appear as you type (minimum 2 characters)
-
Fuzzy matching: Finds results even with minor typos
-
Field boosting: Page titles are weighted higher than content
-
Responsive design: Adapts to different screen sizes
-
Keyboard navigation: Use arrow keys and Enter to navigate results
2.7. Responsive Search Results
The search dropdown automatically adjusts its width based on screen size:
-
Mobile (< 768px): Full-width dropdown with optimized touch targets
-
Tablets (768px - 1199px): Minimum 500px width, up to 80% of viewport
-
Desktop (≥ 1200px): Minimum 600px width, up to 70% of viewport
3. Algolia DocSearch Integration
For sites using Algolia DocSearch (like docs.feelpp.org
), the UI automatically detects and uses the existing configuration.
3.1. Configuration Detection
The UI checks for Algolia configuration in this order:
-
#search-script
element with data attributes -
Global Algolia configuration variables
-
Existing DocSearch initialization
3.2. Setup for Algolia DocSearch
If you want to use Algolia DocSearch:
3.2.1. 1. Add Configuration Script
Add this to your site’s head or before the closing body tag:
<script id="search-script"
data-app-id="YOUR_APP_ID"
data-api-key="YOUR_API_KEY"
data-index-name="YOUR_INDEX_NAME"
data-stylesheet="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css">
</script>
4. Search Behavior
4.1. Automatic Detection Logic
The UI uses this detection logic:
-
Check for Algolia: If DocSearch configuration exists, use Algolia
-
Check for Lunr Index: If
search-index.json
exists, use Lunr.js (automatically generated by @feelpp/antora-extensions) -
Fallback: Show "Search not available" message
5. Troubleshooting
5.1. Lunr.js Issues
- Search index not loading
-
-
Verify
@feelpp/antora-extensions
is installed and configured insite.yml
-
Check that the extension is running during the build process
-
Ensure the generated
search-index.json
is accessible via HTTP(S) -
Check browser console for loading errors
-
- No search results
-
-
Verify the search index contains documents by checking
/search-index.json
in your browser -
Check that page content is being extracted properly (review content selectors)
-
Try rebuilding the site completely
-
- Performance issues
-
-
Large search indexes (>1MB) may cause slow loading
-
Use
exclude_selectors
to remove unnecessary content from indexing -
Consider using
max_content_length
to limit document size
-
- Extension not running
-
-
Verify
@feelpp/antora-extensions
is listed in yoursite.yml
extensions -
Check the terminal output during build for extension loading messages
-
Ensure you’re using a compatible Antora version (3.1+)
-
5.2. Algolia DocSearch Issues
- Search not initializing
-
-
Verify your API credentials are correct
-
Check that the index name matches your Algolia configuration
-
Ensure the DocSearch script is loading properly
-
- Missing CSS styling
-
-
Verify the DocSearch CSS is being loaded
-
Check for CSS conflicts with the UI theme
-
6. Development
6.1. Local Development
For local development with search:
# Build site with automatic search index generation
npm run build
# Start development server
cd build/site
python3 -m http.server 8080
# Open browser to http://localhost:8080
The search index is automatically generated during the build process, so there’s no need for separate search generation commands.
6.2. Search Index Structure
The automatically generated Lunr.js search index has this structure:
{
"documents": [
{
"id": 1,
"title": "Page Title",
"content": "Page content text...",
"url": "/page-path.html"
}
]
}
6.3. Customization
To customize search behavior:
-
Extension configuration: Modify search index generation in
site.yml
-
UI behavior: Edit
src/js/07-search.js
for search logic and UI behavior -
Styling: Modify
src/css/lunr-search.css
for search styling and responsive design -
Content extraction: Use extension configuration options rather than modifying generation scripts
7. Migration from Manual to Automated Search
If migrating from the old manual search setup to @feelpp/antora-extensions
:
7.1. From Manual Lunr.js Setup
-
Remove manual dependencies: Remove
lunr
andjsdom
from devDependencies -
Remove manual scripts: Delete
build:search
andgenerate-search-index.js
-
Add extension: Install and configure
@feelpp/antora-extensions
-
Update build process: Use single
npm run build
command instead ofbuild:full
-
Clean up: Remove old search generation files and scripts
7.2. From Algolia to Lunr.js
If migrating from Algolia DocSearch to automated Lunr.js:
-
Remove Algolia configuration from your site
-
Add @feelpp/antora-extensions to your
site.yml
-
Install the extension via npm
-
Run your normal build - search index will be generated automatically
-
Test search functionality thoroughly
The transition should be seamless as both systems use the same search input element and similar styling.
7.3. Benefits of Automated Approach
-
Zero maintenance: No manual scripts to maintain or copy between projects
-
Consistent behavior: Same search functionality across all Feel++ documentation sites
-
Automatic updates: Extension updates provide improvements and bug fixes
-
Simplified builds: Single command builds everything including search
-
Better performance: Optimized index generation and content extraction