Alias for your Mastodon handle—in the Kirby config.php

Post #8, posted in
  • How to

On Mastodon, there are a few posts about how to implement a custom alias for your actual Mastodon handle using different setups already. Phil Hawksworth wrote about it here (using a Netlify redirect rule) and Trey Piepmeier here (utilising the Redirects plugin in Kirby CMS).
This post here shows you, how you can achieve the same thing with a route in your Kirby config—without any plugin.

After implementation your handle might look something like this:
rather than this:
One of the advantages being, that you will be able to keep that custom handle even if moving to another Mastodon instance.

In your Kirby config.php add a new route like so…

return [
    'routes' => [
            'pattern' => '.well-known/webfinger',
            'action'  => function() {
                if (get('resource') == '') {
                    go('', 200);

…and it works beautifully:

Mastodon search result showing “” for the search term “”.

Wunderbar! 🎉

You gotta use your own alias and handle, of course!1!!

And now what?

Whenever you switch Mastodon instances in the future, your handle will inevitably change.
If you update above route in your Kirby site accordingly, your alias will point there, thus preventing you from having to get new business cards printed—or change whatever else you put your handle on.