Shortcut plugin for Craft CMS
Lets you create short links for elements or arbitrary URLs., (*1)
Installation
You can install Shortcut via the plugin store, or through Composer., (*2)
Craft Plugin Store
To install Shortcut, navigate to the Plugin Store section of your Craft control panel, search for Shortcut
, and click the Try button., (*3)
Composer
You can also add the package to your project using Composer., (*4)
-
Open your terminal and go to your Craft project:, (*5)
cd /path/to/project
-
Then tell Composer to load the plugin:, (*6)
composer require verbb/shortcut
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Shortcut., (*7)
Usage
To create a short url for a element:, (*8)
{% set shortcut = craft.shortcut.get({ element: entry }) %}
{{ shortcut.getUrl() }}
To create a short url for a url:, (*9)
{% 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:, (*10)
<?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., (*11)
<?php
return [
// Hide url segment
'hideUrlSegment' => true,
];
To use a custom domain, add the domain with the customDomain
option., (*12)
<?php
return [
// Set custom domain
'customDomain' => 'https://cool.domain',
];
You can also control the length of the unique hash generated using the hashLength
option., (*13)
<?php
return [
// Set the hash length
'hashLength' => 12,
];
Credits
Originally created by the team at Superbig., (*14)
Show your Support
Shortcut is licensed under the MIT license, meaning it will always be free and open source – we love free stuff! If you'd like to show your support to the plugin regardless, Sponsor development., (*15)
, (*16)