Shortcut

Simple URL shortening

Installation #

To install Shortcut, follow these steps:

  1. Download & unzip the file and place the shortcut directory into your craft/plugins directory
  2. Install plugin in the Craft Control Panel under Settings > Plugins
  3. The plugin folder should be named shortcut for Craft to see it.

Shortcut works on Craft 2.4.x and above.

Shortcut Overview #

Let's you create short urls for elements or url's.

Using Shortcut #

To create a short url for a element:

{% set shortcut = craft.shortcut.get({ element: entry }) %}
{{ shortcut.getUrl() }}

To create a short url for a url:

{% set shortcut = craft.shortcut.get({ url: 'https://cnn.com' }) %}
{{ shortcut.getUrl() }}

By default, short urls is in the format xxxx.tld/s/aBC123. If you want to change the url segment from s to something custom, you can add a config file called shortcut.php in craft/config to override it:

<?php
return [
    // Override Shortcut URL segment
    'urlSegment' => 'x',
];

If you want to remove the url segment completely and get urls like xxxx.tld/aBC123, you can enable the hideUrlSegment option.

<?php
return [
    // Hide url segment
    'hideUrlSegment' => true,
];

To use a custom domain, add the domain with the customDomain option.

<?php
return [
    // Set custom domain
    'customDomain' => 'https://cool.domain',
];

Releases

1.0.3 — 2017-09-06 Download
  • Improved: Added custom domain option
  • Improved: Added option to remove Shortcut url segment completely
1.0.2 — 2017-09-05 Download
  • Improved: Incease url column length to prevent longer urls being truncated
1.0.1 — 2017-09-04 Download
  • Added: Added locale support
  • Added: Added config option for custom url segment
  • Improved: Update saved url when element is updated
  • Improved: Now fetches the url directly from the element instead of using db value
1.0.0 — 2017-06-01 Download
  • Added: Initial release

Currently available for Craft consulting and custom plugin development

Contact me