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.

Checking it works #

The General tab has a Test button, and there is a console equivalent:

Shell
php craft dub/test

Both create a short link, read it back, fetch its QR code and delete it again, reporting each step.

Domains per site #

The General tab also lists every site with its own base URL, so each can have its own short link domain. Each field suggests your Dub domains and accepts an environment variable, exactly like the main one. Leave a site blank, or point it at a variable that isn't defined here, and it uses the Domain above.

An existing link keeps the domain it was created on until its entry is next saved, so after changing a domain run:

Shell
php craft resave/entries

php craft dub/check reports the links still on the old domain as stale in the meantime, so you can see what is left to move.

Setting enabled sections via environment #

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

Plain Text
DUB_SECTIONS=festivals,crew

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