> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postqueen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Short Links

> Wire up a link shortener so she can offer to shorten the URLs in a post

When a post contains a link, she can offer to shorten it and count the clicks. That offer only
appears when a shortener is configured, which is why the option is missing on a fresh install
rather than broken.

Four services are supported. You pick one by setting its API key.

## The rule that catches people

<Warning>
  **Set two keys and the first one silently wins.** The provider is chosen by a first-match chain in
  this order, and nothing warns you that the others are being ignored:

  1. `DUB_TOKEN`
  2. `SHORT_IO_SECRET_KEY`
  3. `KUTT_API_KEY`
  4. `LINK_DRIP_API_KEY`

  The choice is made once when she starts, so changing keys needs a restart, not just a save.
</Warning>

With none of them set, she uses a no-op provider: links go out at full length and she stops
offering to shorten them at all.

## Setting one up

<Tabs>
  <Tab title="Dub">
    ```env theme={"system"}
    DUB_TOKEN="your-api-key"
    DUB_API_ENDPOINT="https://api.dub.co"
    DUB_SHORT_LINK_DOMAIN="dub.sh"
    ```

    Only the token is required. The endpoint defaults to Dub's own API, and the domain to
    `dub.sh`; set `DUB_SHORT_LINK_DOMAIN` to a custom domain you have added in Dub if you want
    links on your own name.
  </Tab>

  <Tab title="Short.io">
    ```env theme={"system"}
    SHORT_IO_SECRET_KEY="your-secret-key"
    ```

    One variable, and there is no endpoint or domain override for this one.
  </Tab>

  <Tab title="Kutt">
    ```env theme={"system"}
    KUTT_API_KEY="your-api-key"
    KUTT_API_ENDPOINT="https://kutt.it/api/v2"
    KUTT_SHORT_LINK_DOMAIN="kutt.it"
    ```

    Kutt is open source, so the endpoint override is the useful one here: point it at your own
    instance and the links stay on infrastructure you run.
  </Tab>

  <Tab title="LinkDrip">
    ```env theme={"system"}
    LINK_DRIP_API_KEY="your-api-key"
    LINK_DRIP_API_ENDPOINT="https://api.linkdrip.com/v1/"
    LINK_DRIP_SHORT_LINK_DOMAIN="dripl.ink"
    ```

    The domain is sent as a custom domain on each link, so set it to one you have configured in
    LinkDrip rather than leaving the default if you want your own.
  </Tab>
</Tabs>

Apply the change the usual way:

```bash theme={"system"}
docker compose down && docker compose up -d
```

## Checking it worked

Write a post containing a link. She asks whether to shorten it, which she does not do when no
provider is configured. Say yes, and the published post carries the short domain you set.

If she never asks, the key is not reaching her. Check for a typo in the variable name, and check
you recreated the container rather than restarting it.

## Related

<CardGroup cols={2}>
  <Card title="Writing a post" icon="pen" href="/using/writing-a-post">
    Where the shortening prompt appears while you write
  </Card>

  <Card title="Analytics" icon="chart-line" href="/using/analytics">
    Click counts come from the shortener, not from PostQueen
  </Card>

  <Card title="Configuration reference" icon="sliders" href="/configuration/reference">
    Every short-link variable in one table
  </Card>

  <Card title="Docker Compose" icon="docker" href="/installation/docker-compose">
    Where to put these variables and how to apply them
  </Card>
</CardGroup>
