Index your build
typemo index reads the HTML pages your build wrote and replaces a collection’s documents with
them. It splits each page into sections exactly as the crawler does, with the
same record ids, so a collection can move between the two. Nothing is fetched from your site, and a
page you delete leaves search with the next deploy.
Before you start
Section titled “Before you start”- Node.js 20.18.1 or newer in your build.
- A Write & Read key from API keys, stored as
TYPEMO_KEYin your CI secrets. - A collection that doesn’t sync on its own. One that syncs from a feed, a store, a database or a crawl refuses the command: its next sync would replace what you sent.
Run it after every build
Section titled “Run it after every build”-
Install the package in your site’s project:
Terminal window npm i -D @typemo-org/cliTerminal window pnpm add -D @typemo-org/cliTerminal window yarn add -D @typemo-org/cliTerminal window bun add -d @typemo-org/cli -
Run
typemo indexon the build output right after the build:package.json {"scripts": {"build": "astro build","postbuild": "typemo index dist --site https://docs.example.com"}} -
Build. The command prints what it skipped and how many records it read, then waits for the import. It ends with
Indexed N records in <collection>; M removed.
The whole set is replaced in one step: until the import succeeds, search keeps the previous documents. A collection without roles gets the crawler’s: Title, Content and URL.
| Option | What it does |
|---|---|
--site <url> | Where the build is served. Needed for any page without its own absolute canonical link. |
--collection <id> | The collection to replace. Needed when the key reaches more than one. |
--clean-urls | Your host serves about.html at /about. |
--output <file> | Write the records to a file and send nothing. See Write a feed file instead. |
--api-url <url> | Another API base, ending in /v1. Also read from TYPEMO_API_URL. |
Which pages are read
Section titled “Which pages are read”Every .html file under the directory, except these. For each reason, the command prints how many
pages it skipped and the first three paths.
| Skipped | Why |
|---|---|
404.html | It’s your not-found page. |
noindex | The page carries <meta name="robots" content="noindex">. |
| Redirect stub | The page carries <meta http-equiv="refresh">, which static hosts write for moved pages. |
| In another language | Its <html lang> differs from the collection’s language. |
| Older docs version | A Docusaurus page of an older or unreleased version. |
Without data-pagefind-body | Some page marks its content with data-pagefind-body, and this one doesn’t. |
| Without a URL | No --site and no absolute canonical link. |
| Without text | The page holds nothing to index. |
Within a page, what becomes a record follows the crawler’s rules: see
What gets indexed from each page. A site that
already marks its content with data-pagefind-body needs no other setup.
Where each result links
Section titled “Where each result links”A page’s own <link rel="canonical"> wins when it’s on the same site. Otherwise the link is
--site plus the file’s path:
| File in the build | Link | With --clean-urls |
|---|---|---|
index.html | / | / |
guide/index.html | /guide | /guide |
guide/setup.html | /guide/setup.html | /guide/setup |
--site may carry a base path, such as https://example.com/docs/.
Write a feed file instead
Section titled “Write a feed file instead”Without an API key in your build, write the records to a file:
typemo index dist --site https://docs.example.com --output dist/typemo.ndjson--output writes one record per line and sends nothing. Deploy the file with your site and point a
product feed at its URL. The command doesn’t know the collection here, so it keeps
pages in every language.
Check it worked
Section titled “Check it worked”The command exits 0 once the import has succeeded, and 1 on any error, so a broken build fails
your CI. Errors include:
TYPEMO_KEYisn’t set and there’s no--output;- the key reaches several collections and
--collectionis missing; - no pages found in the directory;
- the records are over 50 MB, the size limit, and nothing was sent;
- a sync of the collection is running: run the command again once it finishes;
- the import was refused: the command prints each reason, and the collection is unchanged.
Next: Set up the docs widget to search the collection.