Janik von Rotz


1 min read

Mastodon creator tag for your blog posts

This blog post was created using Hugo and the new.css theme that I am developing. When sharing posts on Mastodon, you get a nice preview for links. This is possible by adding OpenGraph meta tags to the html document. In Mastodon you also have the creator tag.

The process on how to get the attribution as creator is described here: https://fosstodon.org/settings/verification

Basically you need to setup two header meta tags in the html of your blog and posts.

With Hugo this is fairly easy to accomplish. Here are the changes I made to the theme:

hugo-new-css-theme/layouts/partials/head.html

{{ with .Site.Params.fediverseCreator }}
<meta name="fediverse:creator" content="{{ . }}" />
{{ end }}

hugo-new-css-theme/layouts/partials/footer.html

{{ with .Site.Params.relMe }}
<a rel="me" hidden="true" href="{{ . }}">Mastodon</a>
{{ end }}

And in my website config I added these two parameters:

config.toml

[params]
    fediverseCreator = "@janikvonrotz@fosstodon.org"
    relMe = "https://fosstodon.org/@janikvonrotz"

And that’s it.

Category: blog
Tags: 100daystooffload , mastodon , opengraph , hugo
Edit Page / Show Statistic