Drupal Module
Sharely.ai for Drupal replaces your site's /search page with search that understands meaning, and adds an Ask mode that answers questions from your own pages, with citations. Every visitor sees only what Drupal lets them see.
Get the module and see a demo at sharely.ai/drupal (opens in a new tab).
What is it?
Sharely.ai for Drupal is a Drupal module that serves Drupal's own /search page and header search box from a Sharely.ai workspace instead of from Drupal core search. Visitors type once and choose between:
- Search — results ranked by meaning, linking to your pages.
- Ask AI — a written answer, streamed to the page, that cites the pages it came from.
The experience stays native to Drupal. It is a core Search plugin rendered with your theme, and nothing is embedded from outside your site.
The module is a client for the hosted Sharely.ai service, so it needs a Sharely.ai workspace. You don't need to create one first: the first time you set up the module, it lets you provision a new workspace right from Drupal. To learn more about workspaces, or to add another one later, see Add a new workspace.
What problems does it solve?
Drupal's core search matches words, not meaning. Someone who misspells a word, uses a synonym, or asks a question in plain language often never gets the page they needed.
The module addresses that, and some related concerns:
- Missed results. Visitors find pages by what they mean, not only by the exact words on the page.
- Questions without answers. Visitors can ask a question and get an answer written from your content, rather than a list of links to read through.
- Access control. An AI search feature must not leak restricted content. The module carries Drupal's permissions into Sharely and checks them again before anything is shown.
- Fragile integrations. If the workspace is unreachable, search falls back to Drupal core search instead of breaking.
What benefits does it provide?
- Native to Drupal. A core Search plugin serves
/searchand the header search box. - Search or Ask. One choice at the search box. Only the chosen mode runs, so asking never also costs a search.
- Answers with citations. Each citation is resolved through Drupal, so its title and link are the page's own. A page the visitor can't view is never cited.
- Themed like the rest of your site. The search experience is a Single Directory Component that uses your theme's CSS custom properties.
- Access-aware. Drupal roles are mirrored into Sharely, every page is tagged with the roles allowed to view it, and results are filtered against Drupal again before they render.
- Kept in step. Changes sync in the background as editors save, and a status page shows what has and hasn't synced.
- Search activity. The status page counts what visitors searched for and, more usefully, what found nothing. It records query text and result counts only: no user, session or IP address, and nothing is sent to Sharely.
- Ready for AI agents. The same knowledge your visitors search is available to AI agents, under the same access rules. See the Platform Overview.
Before and after installation
| Before | After | |
|---|---|---|
| Search engine | Drupal core search, which matches the words typed | Sharely.ai, which ranks results by meaning |
| Misspellings and synonyms | Often return nothing | Still find the right page |
| Questions in plain language | Return a list of loosely matching pages | Switch to Ask for a written answer with citations |
| Search page | /search, rendered by core | The same /search and header search box, now served by Sharely |
| Content in Sharely | None | Published nodes are synced to your workspace and kept current as editors save |
| Visibility rules | Drupal permissions | Drupal permissions, mirrored as Sharely roles and checked again before render |
| If the service is unavailable | Not applicable | /search falls back to Drupal core search with a notice |
Disconnecting or uninstalling the module returns you to the "before" column. Your Sharely workspace is left untouched.
Requirements
- Drupal 11.4 or later. The module needs core's Search Node module, which arrived in 11.4.
- PHP 8.2 or later. The module has no third-party PHP libraries.
- Composer, to install the module.
- A Sharely.ai workspace, created for you when you connect.
- Cron, for sites above the in-browser sync threshold. See Content sync.
Note: Published content is sent to Sharely. Page text, title and URL are sent and stored there, tagged with the Drupal roles that may view them. Unpublished content and pages visible only through per-user grants are never sent.
How to install it
Run these commands from your Drupal project:
composer require drupal/sharelyai
drush cr
drush recipe modules/contrib/sharelyai/recipes/sharelyai_searchThe recipe installs the module and core search, makes Sharely the default search page, and lets visitors search. Applying it again is safe.
Two details matter:
- Rebuild caches (
drush cr) before applying the recipe so Drupal sees the new module. - Give the recipe path from the docroot,
modules/contrib/…, notweb/modules/contrib/….
Using DDEV or Lando? Prefix each command with ddev or lando.
Without Drush
Use core's own tool, and rebuild caches before and after the recipe. Otherwise /search answers "Page not found".
vendor/bin/dr cr
vendor/bin/dr recipe modules/contrib/sharelyai/recipes/sharelyai_search
vendor/bin/dr crWithout the recipe
Enable the module at Extend, then give the Anonymous and Authenticated roles the Use search permission at People → Permissions. Drupal 11.4's Standard profile doesn't grant it.
How to set it up
- In Drupal, go to Configuration → Search and metadata → Sharely.ai for Drupal.
- Click Connect to Sharely. Sign in to Sharely, or create an account.
- Approve the site. You are returned to Drupal connected. There is no API key to paste.
- The first sync starts. Search works within minutes, and when the first sync finishes
/searchis already answered by Sharely.
Content sync
Published nodes are sent to your workspace in the background and kept in step as editors save.
- Small sites sync in the browser, with a progress bar.
- Larger sites fill a queue that cron drains.
- Failures retry with backoff, rate limits pause the run, and every failure is listed with its reason.
The module's status page shows what has synced and what hasn't.
How to integrate it into your existing Drupal environment
The module is designed to slot into the search you already have rather than add a new page.
- Your search URLs stay the same. Visitors keep using the same search box and the same
/searchpage. - Your theme applies. The search page is a Single Directory Component, so it picks up your theme's styling.
- Your roles apply. Drupal roles are mirrored to Sharely roles, and every page is tagged with the roles allowed to view it. An anonymous visitor gets anonymous results.
- Field-level access is respected. A field is sent only if every role tagged on the page may view it, so internal or hidden fields never reach Sharely.
- Page caching stays safe. Nothing about a visitor is rendered into cacheable HTML. Identity is minted on your server per request.
- Abuse protection. New anonymous visitor identities are rate limited per IP address (300 an hour by default, adjustable). Over the limit, search falls back to core results.
- Configuration management. If you deploy configuration, run
drush cexand commit after installing, updating or uninstalling.
The workspace, its API key and the Sharely URLs aren't editable in the Drupal UI by design. The key comes from the connection and is kept out of configuration exports, and the URLs belong to the deployment. See settings.example.php in the module for the deployment-level settings.
How to customize it
Settings in the UI
At Configuration → Search and metadata → Sharely.ai for Drupal, you can change:
- Which content types and text fields are read.
- Whether Ask is offered.
- What a bare search link opens with (Search or Ask).
- The number of results per page.
- How long search statistics are kept.
Override the search page in your theme
The search experience is a Single Directory Component named sharelyai:search-experience. Override it the Drupal way, using replaces in your theme's component definition:
replaces: sharelyai:search-experienceYour theme's override then renders in place of the module's. The component uses your theme's own CSS custom properties, so many styling changes need no override at all.
Change what is sent and who can see it
Two hooks let a custom module adjust the sync:
hook_sharelyai_document_alter()changes the document sent to Sharely for a page.hook_sharelyai_roles_alter()changes which roles may view it.
Update and uninstall
Update
composer update drupal/sharelyai
drush updatedb
drush crDrush asks you to confirm the updates. Press Enter for Yes, or add -y.
If you're coming from 1.0.0-alpha1 or 1.0.x-dev, run composer require drupal/sharelyai:^1.0 once instead of composer update, because those versions are pinned in composer.json.
Uninstall
Uninstall before removing the code:
drush pm:uninstall sharelyai
composer remove drupal/sharelyai
drush cr
drush cronUninstalling restores core search and tells Sharely the site is gone. Cron then builds core's search index, which wasn't filled while Sharely served search. If the code was removed first, restore it with composer require drupal/sharelyai and drush cr, then uninstall and remove it.
You can also disconnect from the module's settings. That stops the sync and returns your search page to Drupal core search.
Learn more
- Sharely.ai for Drupal (opens in a new tab): overview, demo and download.
- Platform Overview: how the same workspace can index other sources and run agents.
- Knowledge Synchronization: sync content from other systems programmatically.
- WordPress Plugin: the equivalent for WordPress sites.