Adding a "reply via email" button to Bear Blog
There's a bit of controversy among the users of Bear Blog concerning whether visitors should be able to comment or not on blog posts. I don't think we should have comments (they are more of a hassle to moderate than useful), but it's nice to receive feedback and start conversations with the readers.Â
A "Contact" item already exists on the main menu, but in most cases there's a specific post that sparks a discussion and motivates whoever's reading to send an e-mail. I saw an "reply via email" button on Luke Harris' blog and also on micro.blog, so I wanted to throw one in here as well.
It's simple: I add this line to the end of each blog post:
##### [Reply via email](mailto:myawesomeemail@provider.com)
I've styled the h5 tag to look like a button, because I don't think I will use h5 heading anywhere else.
I would also like to add a default email subject to the message, but unfortunately I couldn't get mailto:myawesomeemail@provider.com?subject=Re:%20Adding%20a%20reply%20via%20email%20button%20to%20bear%20blog to work. I think this is a limitation in the markdown markup.Â
I'm really happy with this reply button, though.
Updated in 2024-01-05: Thanks to those of you who read this, I was able to make some improvements: if I use HTML instead of markdown, I can include the subject line AND use the post attribute tag, which will add the corresponding post title automatically:
{{ post_title }}
The improved version is this one:
<h5><a href="mailto:myawesomeemail@provider.com?subject=Re:%20{{ post_title }}">Reply via email</a></h5>
I'm inserting the code manually at the end of each blog post, because post templates are not working for me. Maybe it's a bug. This isn't a big issue, because I can use AutoHotkey to write the whole code easily: I just need to input the keyword I've created for it (for example, ;rvm) and AHK replaces it with the whole HTML code.
As a Bear Blog subscriber, I could also insert the code on the blog's footer and it would be displayed in all pages, but I'm still thinking about what to do with my footer and I like to have the button above the post tags.
Updated in 2024-01-06: To prevent spam I'm using an email alias on the reply button instead of my personal email address.
Updated in 2024-01-14: Post templates work fine. I didn’t know you had to insert the following before the template text itself:
___
Updated in 2024-01-18: If you are a Bear subscriber and want to add the code to the footer while hiding it from both the home and posts' list (blog) pages, you can use display: none; in the CSS, like this:
body.home footer #footer-directive h5 {
display: none;
}
body.blog footer #footer-directive h5 {
display: none;
}
Special thanks to:
- Steve, for reminding me I could use HTML instead of markdown
- Kev Quirk, for requesting the attribute tags to Herman and telling me about them
- Raveen Kumar, for the tip about Bear's footer
- Peter, for reminding me about the potential risk of receiving too much spam associated with displaying email addresses in clear text format. That's why I edited out my email address from the examples above
- Aravind, who suggested writing about using aliases to prevent spam
- Jeff, who told me how to make post templates work
- Darsh, who emailed me the code to hide the reply button in the footer of both the home and blog pages