I have my own domain, and I have a mastodon account. When I read Scott Hanselman’s blogpost Use your own user @ domain for Mastodon discoverability with the WebFinger Protocol without hosting a server, I didn’t wait long before… adding that as a todo to my list.
Upon reading it, I found that it explained the concept of Webfinger quite well. Still, it was Maarten Balliauw whose comment drew my attention to his post on how to do this for a static website, notably Jekyll.
I wanted to do the same, and with Hugo already set up I startet the journey:
First, find the info about your mastodon profile
In a browser, or using curl, open:
This gives you a JSON text bit of all you need to do the redirect.
Second, in your site’s static folder (outside of content)
Create a folder named
.well-known. Inside this folder create a file named
webfinger (like that, no file extension)
Inside this file, paste all the json from the first part. Thats that,
Thirdly, just to be sure
Run Hugo with
hugo server and open localhost:1313/.well-known/webfinger?resource=acct:firstname.lastname@example.org
Now it is just to generate and publish your site, and it should be working. Test it out by searching for
email@example.com in Mastodon.
Note: there are no logic involved
Any username and your domain will return the same Mastodon redirect. If it should do any redirect, that will be another bit of work — and possibly not in Hugo?