Adding "Reply via email" to a hugo site
We’re not all running our blogs on ActivityPub yet, so how do we allow people to
comment on our posts? The most straightforward way for me was to simply add a
link to email me about a post to the posts, with an automatically populated
Subject:
header based on the title of the post.
The below snippet can be used on your blog post layout to have Hugo add a link
that will open a mail client with your e-mail and the Re: Your blog post title
already filled out:
<a href="mailto:{{ $.Site.Author.email }}?subject={{ replace (printf "Re: %s" .Page.Title) "\"" "'" }}">reply via email</a>
Double quotes in the blog title are replaced with single quotes to not mess up the HTML.
The $.Site.Author.email
value comes from your Hugo configuration file (in my
case, config.toml
. That section like this:
[author]
name = "John Doe"
email = "[email protected]"
You can also simply hardcode your mail address into your template, if you don’t wanna specify it globally.
reply via email