Categories
Development How To WordPress

Verify your WordPress website on Mastodon

If you’re using Mastodon, then it’s possible to verify your website links in your profile. When done, you’ll see something like this…

The green background and tick shows it’s been verified as belonging to you.

Here’s how you do it..

This is the most complex way to do it, but is the cleanest.

  1. Add the following code to your functions.php file, which is in your theme folder
function add_mastodon_verification() {
?>
<link rel="me" href="[your Mastodon profile link]">
<?php
}
add_action( 'wp_head', 'add_mastodon_verification' );
view raw functions.php hosted with ❤ by GitHub
  1. Replace the bit in brackets (inc. the brackets) with a link to your Mastodon profile.

The only problem with this method is that if your theme gets an update, it’s likely the file will get reset back again.

In addition, if you’re using WordPress.com then you may not be able to edit this file anyway. In both cases, another solution is to use a plugin that can insert just the line of code into the header that you need. The line in question is the 3rd one…

<link rel="me" href="[your Mastodon profile link]">

The plugin I’m using for artiss.me, which is on WordPress.com, is WPCode, but there are many other alternatives available.

Add a link to your home page

This is the simple method. Indeed, it will work on any website, not just WordPress.

  1. Somewhere on your home page, add a link to your Mastodon profile. However, you’ll need to change the code by adding rel="me" to the anchor. It should end up looking something like this…
<a rel="me" href="[your Mastodon profile link]">My Mastodon profile</a>
  1. As with the previous method, you just need to replace the bit in brackets (inc. the brackets) with a link to your Mastodon profile.

Whichever of the above methods you used, you’ll now need to do the following to add your site to Mastodon…

  1. Go to Mastodon and click on “Edit Profile”
  2. Under Profile Metadata add a link to your website

And that’s it. Give it a while for your Mastodon server to recognise the link but when that’s done, expect to see that lovely green, verified confirmation.

For both this site and artiss.me, I’ve used both methods (because a bit of overkill would never do any harm, right?), so feel free to check out the source code to see what the final result looks like.

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

css.php
%d bloggers like this: