PHPackages                             bensomething/craft-dub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bensomething/craft-dub

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

bensomething/craft-dub
======================

Create Dub short links for your entries.

1.3.0(2w ago)028MITPHPPHP &gt;=8.2CI passing

Since Mar 23Pushed 2w agoCompare

[ Source](https://github.com/bensomething/craft-dub)[ Packagist](https://packagist.org/packages/bensomething/craft-dub)[ RSS](/packages/bensomething-craft-dub/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (4)Dependencies (7)Versions (11)Used By (0)

Dub Links
=========

[](#dub-links)

Create Dub short links for your entries.

Requirements
------------

[](#requirements)

- A [Dub](https://refer.dub.co/bensomething) account (affiliate link) and API key. [Learn more.](https://dub.co/docs/api-reference/authentication#api-keys)
- Craft CMS 5.0.0 or later.
- PHP 8.2 or later.

Installation
------------

[](#installation)

To install the plugin, search for "Dub" in the Craft Plugin Store, or install manually using composer.

```
composer require bensomething/craft-dub

```

Then install the plugin via the Craft control panel under **Settings → Plugins**, or from the terminal:

```
php craft plugin/install dub

```

Configuration
-------------

[](#configuration)

1. Go to **Settings → Plugins → Dub Links** in the Craft control panel.
2. On the **General** tab, enter your Dub API key. You can use an environment variable (e.g. `$DUB_API_KEY`).
3. After saving your API key, the **Domain** field will suggest your available domains. Pick one, or use an environment variable (e.g. `$DUB_DOMAIN`).
4. In the **Sections** field, choose which sections to enable short links for. Leave **All** selected to enable every section that has URLs.
5. On the **Sidebar** tab, choose how the **QR code** appears in the entry sidebar (**None**, **Icon**, or **Full**), set its **style** (size, margin, foreground/background colour), and choose whether to **Show click count**.

### Setting enabled sections via environment

[](#setting-enabled-sections-via-environment)

You can override the **Sections** selection with the `DUB_SECTIONS` environment variable, a comma-separated list of section **handles**:

```
DUB_SECTIONS=festivals,crew

```

When set, it takes precedence over the control panel selection (which is shown as read-only in the settings).

Usage
-----

[](#usage)

Once configured, a **Short Link** panel will appear in the sidebar of any entry that belongs to a section with URLs.

- **Creating a short link:** enter a custom slug in the **Short Link** sidebar section and save the entry. If left blank, no short link is created.
- **Updating a short link:** update the short link slug in the sidebar and save. The existing Dub link is updated in place.
- **Deleting a short link:** a short link will be removed from Dub when an entry is deleted or when a short link slug is removed and the entry is saved.
- **Archiving a short link:** a short link will be archived in Dub when an entry is disabled.
- **QR code:** depending on the **Sidebar → QR code** setting, a QR code for the short link is shown in the sidebar as a small icon or a full image.
- **Click count:** enable **Sidebar → Show click count** to display a read-only click total for the short link in the sidebar.

Adopting existing links
-----------------------

[](#adopting-existing-links)

If your Dub workspace already contains short links for your entries — created manually or before installing the plugin — you can hand them over to the plugin in one pass:

```
php craft dub/adopt

```

This scans your workspace, matches each link to a Craft entry by the path of its destination URL, sets the entry's `externalId` on the link so the plugin manages it going forward, and records it locally. Links with no matching entry (or a path shared by more than one site) are left untouched.

Add `--dry-run` to preview what would be adopted without making any changes:

```
php craft dub/adopt --dry-run

```

If some of your Dub links point to an old path prefix, use `--rewrite` to remap the destination path when matching. It only applies as a fallback, when the link's original path matches no entry. Pass one or more comma-separated `from=to` prefixes:

```
php craft dub/adopt --rewrite="/areas-stages/=/venues/"

```

Templating
----------

[](#templating)

Use the `dubLink(entry)` Twig function to output a short link in your templates:

```
{% set shortLink = dubLink(entry) %}
{% if shortLink %}
    {{ shortLink }}
{% endif %}
```

Use the `dubQr(entry)` Twig function to output the short link's QR code image:

```
{% set qr = dubQr(entry) %}
{% if qr %}

{% endif %}
```

[![Dub plugin sidebar](resources/craft-dub-1.png)](resources/craft-dub-1.png)

[![Stable Version](https://camo.githubusercontent.com/4ea62f5d2df8ce0b8233ab9c769db67aaff644b2064941c95fc58e43ea4163d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656e736f6d657468696e672f63726166742d6475623f6c6162656c3d737461626c65)](https://packagist.org/packages/bensomething/craft-dub)[![Total Downloads](https://camo.githubusercontent.com/7febea564851bfeeab62cee847c193aaf8e81476eb6699675f3722c70e984dfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62656e736f6d657468696e672f63726166742d647562)](https://packagist.org/packages/bensomething/craft-dub)

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance97

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~30 days

Total

7

Last Release

16d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e62c094901d7c5d75b18d3a34478f63b2adefe61ca1e32e877f742216c4afe2?d=identicon)[bensomething](/maintainers/bensomething)

---

Top Contributors

[![bensomething](https://avatars.githubusercontent.com/u/48893?v=4)](https://github.com/bensomething "bensomething (61 commits)")

---

Tags

craft-plugincraftcmscraftcms-plugin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bensomething-craft-dub/health.svg)

```
[![Health](https://phpackages.com/badges/bensomething-craft-dub/health.svg)](https://phpackages.com/packages/bensomething-craft-dub)
```

###  Alternatives

[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

393818.3k12](/packages/spicyweb-craft-neo)[craftcms/feed-me

Import content from XML, RSS, CSV or JSON feeds into entries, categories, Craft Commerce products, and more.

292960.7k37](/packages/craftcms-feed-me)[verbb/formie

The most user-friendly forms plugin for Craft.

101400.6k76](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54686.7k24](/packages/solspace-craft-freeform)[verbb/hyper

A user-friendly links field for Craft.

24153.5k14](/packages/verbb-hyper)[verbb/vizy

A flexible visual editor field for Craft.

4251.5k1](/packages/verbb-vizy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
