Overview
The DocSearch crawler uses a JSON configuration file to define how it should crawl and index your documentation. This configuration specifies which pages to crawl, what content to extract, and how to structure the searchable records.While the crawler runs in the algolia/docsearch-scraper repository, you manage your configuration through the Algolia Crawler Dashboard if you’re using the free DocSearch program.
Basic Configuration
A minimal DocSearch configuration looks like this:Required Fields
index_name
The name of your Algolia index where records will be stored.
start_urls
An array of URLs where the crawler begins. It will recursively follow links from these pages.
Advanced Start URLs
You can provide objects with additional options:selectors
Defines CSS selectors for extracting content and building the hierarchy.
The
text selector is required. We recommend setting at least lvl0, lvl1, and lvl2 for good search depth.Selector Options
String Selectors
The simplest form uses CSS selector strings:Object Selectors
For more control, use objects with additional properties:Global Selectors
Mark selectors asglobal to extract the same value for all records on a page:
Global selectors are useful for page-level metadata like the current section. Avoid making
text selectors global.Default Values
Provide fallback text when a selector matches nothing:Strip Characters
Remove decorative characters from extracted text:XPath Selectors
For complex DOM traversal, use XPath instead of CSS:Multiple Selector Sets
Different pages often have different markup. Useselectors_key to apply different selectors:
Always include a
default selector set as a fallback.Optional Configuration
stop_urls
Prevent the crawler from visiting certain URLs:
selectors_exclude
Remove elements from pages before extraction:
Use this to exclude navigation, footers, or other repetitive content that shouldn’t be indexed.
scrape_start_urls
Skip extracting content from the start URLs themselves:
min_indexed_level
Only index records with a minimum hierarchy depth:
min_indexed_level: 2, only records with at least lvl0, lvl1, and lvl2 set will be indexed.
only_content_level
Index only text content, not headings:
Advanced Features
URL Variables and Faceting
Extract variables from URLs for filtering:Custom Tags
Add arbitrary tags to pages:Page Rank
Boost specific pages in search results:Sitemap-Based Crawling
Use XML sitemaps instead of following links:JavaScript Rendering
Enable Browser Emulation
For client-side rendered sites:Wait for Content
Give slow sites time to render:Hash-Based URLs
For single-page apps using URL fragments:Custom User Agent
Override the default user agent:- Without
js_render:Algolia DocSearch Crawler - With
js_render: Chrome headless user agent
Algolia Settings
Custom Index Settings
Override default Algolia settings:The default settings are optimized for documentation. Only change if you have specific requirements.
Synonyms
Define term equivalencies:Configuration Examples
Simple Documentation Site
Multi-Version Documentation
API Reference with Guides
Testing Your Configuration
1
Create Configuration
Write your JSON configuration based on your site’s HTML structure.
2
Test Selectors
Use browser DevTools to verify selectors match the correct elements.
3
Run Test Crawl
If self-hosting, run a test crawl locally. For the free program, test in the Crawler Dashboard editor.
4
Verify Results
Check indexed records in the Algolia Dashboard to ensure proper extraction.
Next Steps
Getting Started
Learn how the crawler works
Apply to DocSearch
Get free hosting for your open source project
Additional Resources
Algolia Crawler Documentation
Complete Algolia Crawler reference
Example Configurations
Browse real-world DocSearch configurations
