How Algolia Search works in this website ?

This website uses Algolia Search to power the search form shown on the homepage and the search modal. The Algolia account used for this integration is managed through nuwanjaliyagoda[at]eng.pdn.ac.lk and the CE GitHub webmaster account.

1. Where the frontend gets the Algolia credentials

The browser-side configuration is injected from _includes/head.html . It publishes:

window.ALGOLIA_CONFIG = {
  appId: "...",
  searchApiKey: "..."
};

These values come from environment variables first, and fall back to the values in _config.yml .

2. How the search UI works

The search box markup is in _includes/search_form.html , and the search results modal is in _includes/search_modal.html . The client-side logic lives in assets/js/search.js .

When a user submits a query, the script:

  1. Reads the query from the search form.
  2. Builds Algolia requests for two indices: staff_profiles and student_profiles .
  3. Sends both requests using the Algolia JavaScript client.
  4. Merges the hits, removes duplicates using the page URL, and renders the results in the modal.
  5. Shows pagination in the modal when the number of matches is large.
queries.push({ indexName: "staff_profiles", query: query, params: params });
queries.push({ indexName: "student_profiles", query: query, params: params });

3. How data is prepared for Algolia

The indexing script is python_scripts/algolia_index.py . It reads the site content and converts it into Algolia records.

For each record, the script extracts key searchable fields such as name, title, registration number, interests, current affiliation, email addresses, and page content.

Index settings such as searchable attributes, facets, typo rules, and ranking are defined in python_scripts/util/configs.py .

4. How the Algolia indices are updated

The index update job is defined in .github/workflows/algolia-index.yml . It can run in two ways:

The workflow does the following:

  1. Checks out the repository.
  2. Builds the Jekyll site.
  3. Installs Python dependencies from requirements.txt .
  4. Runs python_scripts/algolia_index.py .
  5. Replaces the contents of the Algolia indices and reapplies index settings.

The script uses the Algolia Admin API key for indexing, while the website itself uses only the search API key for read-only client-side queries. All the credentials are stored securely in GitHub Actions secrets and environment variables.

5. What to update if search stops working