Skip to content

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.

  • Node.js 20.18.1 or newer in your build.
  • A Write & Read key from API keys, stored as TYPEMO_KEY in 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.
  1. Install the package in your site’s project:

    Terminal window
    npm i -D @typemo-org/cli
  2. Run typemo index on the build output right after the build:

    package.json
    {
    "scripts": {
    "build": "astro build",
    "postbuild": "typemo index dist --site https://docs.example.com"
    }
    }
  3. 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.

OptionWhat 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-urlsYour 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.

Every .html file under the directory, except these. For each reason, the command prints how many pages it skipped and the first three paths.

SkippedWhy
404.htmlIt’s your not-found page.
noindexThe page carries <meta name="robots" content="noindex">.
Redirect stubThe page carries <meta http-equiv="refresh">, which static hosts write for moved pages.
In another languageIts <html lang> differs from the collection’s language.
Older docs versionA Docusaurus page of an older or unreleased version.
Without data-pagefind-bodySome page marks its content with data-pagefind-body, and this one doesn’t.
Without a URLNo --site and no absolute canonical link.
Without textThe 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.

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 buildLinkWith --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/.

Without an API key in your build, write the records to a file:

Terminal
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.

The command exits 0 once the import has succeeded, and 1 on any error, so a broken build fails your CI. Errors include:

  • TYPEMO_KEY isn’t set and there’s no --output;
  • the key reaches several collections and --collection is 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.