---
title: "extract"
description: "Split every source into segments and write a manifest for each."
canonical_url: "https://diglot.sh/workflow/cli/extract"
---
# extract

> Split every source into segments and write a manifest for each.

`diglot extract` reads each source, splits every document into [segments](https://diglot.sh/guide/concepts/segments) with the parser from your configuration, and writes the result to `.diglot/manifest/<source>.json`. The manifest is what later runs compare against, so extraction is the step that records the current state of a source.

```bash
pnpm dlx @diglot/cli extract [--source name]
```

## Options

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --source
      </code>
    </td>
    
    <td>
      all sources
    </td>
    
    <td>
      Extract only this source. An unknown name is an error that lists the configured sources.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --cwd
      </code>
    </td>
    
    <td>
      <code>
        .
      </code>
    </td>
    
    <td>
      The translations repository root
    </td>
  </tr>
</tbody>
</table>

## Output

For each source, the command prints the number of files, the number of segments and the number of unique hashes, then the manifest path:

```text
<source>: <files> files, <segments> segments, <unique> unique hashes -> .diglot/manifest/<source>.json
```

The gap between segments and unique hashes is the repetition inside the source: the more repeated text, the fewer translations you need.

## Which files are read

Markdown files are read with comark, or with mdast when `parser` is `mdast`. `.yml` and `.yaml` files, which by default means `.navigation.yml`, are read as navigation files. Files must match the source's `include` patterns and not its `exclude` patterns, and the source must have a `path` that exists. See [define sources](https://diglot.sh/guide/how-to/sources).

Next to the manifests, the command writes a snapshot of your policy to `.diglot/policy.json`, and each manifest records the policy's fingerprint. A server that applies translations at runtime needs that snapshot to extract segments the same way, so commit it with the manifests. See [snapshots](https://diglot.sh/core/policy-and-config#snapshots).

The manifest stores each segment's hash, kind, format, word count and skeleton, plus the placeholder types and the salt when there are any. It doesn't store the markdown of protected spans, because identities don't depend on it.


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
