Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link to a fediverse/Mastodon account in HTML?

Tags:

html

When I want to link to an email from a webpage, I use mailto: like

<a href="mailto:[email protected]">Mail me!</a>

Now, how to link to a federated Mastodon handle like @[email protected]? I can get around the problem by linking the webpage of the user (domain.org/@user), but I wonder whether there is a way to let the client handle the link using user's preferred client, just like in the case of e-mail.

like image 465
Lukáš Lánský Avatar asked Sep 20 '25 21:09

Lukáš Lánský


1 Answers

Not really, no. I asked about a URI scheme in the early days - see https://mastodon.social/@Edent/2094622

It might be nice to have mastodon://mastodon.social/@edent - but that link just wouldn't work for anyone who didn't have an app which could handle it.

The web has won. Everything is an https:// link now - with some legacy exceptions like tel: and mailto:

So, what's the solution?

When your web browser makes an HTTP request to a Mastodon server, this HTTP header is returned (formatted for clarity):

server: Mastodon
...
link:
  <https://mastodon.social/.well-known/webfinger?resource=acct%3AEdent%40mastodon.social>;
  rel="lrdd";
  type="application/xrd+xml", <https://mastodon.social/users/Edent.atom>;
  rel="alternate";
  type="application/atom+xml", <https://mastodon.social/users/Edent>; 
  rel="alternate"; 
  type="application/activity+json"

If the server name doesn't give your browser a clue which app to open, hopefully the webfinger stuff, or alternate links, will.

like image 54
Terence Eden Avatar answered Sep 22 '25 17:09

Terence Eden