Mastodon Verification with Hugo and Cloudflare Pages
I’ve moved my blog over to Cloudflare Workers, and Astro, instead of pages and Hugo, but I’m keeping this published as most of the info is still valid
I run my blog on Cloudflare Pages, using Hugo to generate the specific static pages. I recently set up my own Mastodon server with my own domain as well, at barnes.social, and I wanted to verify my blogs website on my Mastodon account. It wasn’t immediately obvious to me how to do that, so I thought I would write out what I ended up needing to do.
In a Hugo-generated website, you’ll typically add the rel="me" link to one of the template files in the layouts folder. The specific file depends on your site’s structure and theme.
Here are some common places to add the rel="me" link:
layouts/partials/header.htmlorlayouts/partials/head.html: Add therel="me"link in the header section, which will include it on every page.layouts/partials/footer.html: Add therel="me"link in the footer section, which will include it on every page.layouts/partials/sidebar.htmlorlayouts/partials/navigation.html: Add therel="me"link to a sidebar or navigation menu, which will typically include it on every page.
If you are using a theme, you may need to copy the relevant file from the theme’s layouts folder (for instance., themes/your-theme/layouts/partials/header.html) to your site’s layouts folder (for instance, layouts/partials/header.html) before making the changes. This will ensure you’re modifying your site’s layout, not the theme’s default layout.
Once you’ve located the appropriate file, add the rel="me" link, which can be found on your Mastodon account. It will look similar to this:
<a href="https://your-mastodon-instance.example/@yourusername" rel="me">My Mastodon Profile</a>htmlReplace your-mastodon-instance.example with your Mastodon instance’s domain, and @yourusername with your Mastodon username.
It can take a few minutes for the verification to happen, and unfortunately there’s no way (that I could find anyway) to manually tell your account or server to check now, however it seemed to take only a couple of minutes.