Mastodon Verification with Hugo and Cloudflare Pages

 

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:

  1. layouts/partials/header.html or layouts/partials/head.html: Add the rel="me" link in the header section, which will include it on every page.
  2. layouts/partials/footer.html: Add the rel="me" link in the footer section, which will include it on every page.
  3. layouts/partials/sidebar.html or layouts/partials/navigation.html: Add the rel="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>

Replace 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.