Simple URL shortening
This plugin requires Craft CMS 3.0.0-beta.23 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to load the plugin:
composer require superbig/craft3-shortcut -
In the Control Panel, go to Settings → Plugins and click the “Install” button for Shortcut.
Let's you create short links for elements or arbitrary URLs.
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',
];Brought to you by Superbig