bensomething/craft-dub

Create Dub short links for your entries.

Maintainers

Package info

github.com/bensomething/craft-dub

Type:craft-plugin

pkg:composer/bensomething/craft-dub

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.3 2026-03-23 13:50 UTC

This package is auto-updated.

Last update: 2026-04-24 17:50:24 UTC


README

Create Dub short links for your entries.

Requirements

  • A Dub account (affiliate link) and API key. Learn more.
  • Craft CMS 5.0.0 or later.
  • PHP 8.2 or later.

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

  1. Go to Settings → Plugins → Dub in the Craft control panel.
  2. Enter your Dub API key. You can use an environment variable (e.g. $DUB_API_KEY).
  3. After saving your API key, the Domain section will display a dropdown of your available domains.

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.

Templating

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

{% set shortLink = dubLink(entry) %}
{% if shortLink %}
    <a href="{{ shortLink }}">{{ shortLink }}</a>
{% endif %}

Dub plugin sidebar

Stable Version Total Downloads