Skip to content

Commit 6100308

Browse files
SarasateKyleAMathews
authored andcommitted
Blog Post - Comments with Gatsby (#4916)
1 parent 17dd9fa commit 6100308

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: How to handle comments in Gatsby blogs
3+
date: "2018-04-09"
4+
author: "Gatsby Central"
5+
canonicalLink: https://www.gatsbycentral.com/how-to-handle-comments-in-gatsby-blogs
6+
publishedAt: "Gatsby Central"
7+
---
8+
9+
> tl;dr Hosted services like diqus are the easiest. Staticman is the best option, but requires some setup.
10+
11+
You have a static site. Or you will have. You understand how the content will work. But what about comments?
12+
13+
You have three choices.
14+
15+
* Keep comments in git.
16+
* Use client side comment service.
17+
* Do something crazy.
18+
19+
## Client side
20+
21+
The second is the simplest choice. [Disqus](https://disqus.com/) is a popular client side comment service. They offer a free tier for non-commercial sites. Or plans start from $10/month.
22+
23+
There are also open source alternatives like [commento](https://github.com/adtac/commento). You need to install them. You need to manage and maintain a server. This is probably too much work to be worthwhile.
24+
25+
How do they work? You insert a javascript tag. That loads the comment service. It inserts the comments **client side**. This means your comments are not part of your Gatsby output. This means Google probably won't see them.
26+
27+
## Comments in git
28+
29+
Putting the comments inside git is awesome. Your content, your site, no external dependencies. Fantastic.
30+
31+
### Staticman
32+
33+
But how do you get them there? Enter [staticman](https://staticman.net/). You give staticman access to your GitHub repo. You create a form. Staticman creates a pull request. It also supports akismet spam filtering. Genius. Oh, and it's free. Yes, doubly fantastic.
34+
35+
Staticman is open source. You can run your own instance. If you really want to. It's probably not worth it. Their service is free. They don't "own" your data. If they disappear, your comments live on.
36+
37+
### Roll your own
38+
39+
You could create your own staticman alternative. You could use a framework like [serverless](https://serverless.com/). You can find free hosts for serverless. You can write your own custom anti spam logic. This will be hard. It will probably be fun. It's not a very good idea!
40+
41+
### Netlify
42+
43+
Are you hosting on [netlify](https://serverless.com/)? Then you could use their forms service. If you pay for netlify, you can link forms to functions. Similar to serverless. You could use that to make PRs. Or push content to GitHub. Or other git hosts. Too complicated. Not worth it.
44+
45+
### Email
46+
47+
You could link your comment form to an email address. Then you could copy and paste comments into git. Manual comment moderation. Maybe with netlify's form service? Or a serverless setup. Again, this could be fun to setup. Again, it's probably not a very good idea!
48+
49+
## Crazy
50+
51+
There are many other options. Some crazier than others. You could push comments to WordPress. Then pull them from WordPress into Gatsby at build time. Or push them to a headless CMS. Via a serverless setup maybe.
52+
53+
You could create a comment form. Then have it generate a mailto link. Then people email you the comment. Then you copy and paste it into git. Or the mailto link points to a service like mailgun. Then incoming emails turn into webhooks. Then forward to serverless. Then land as pull requests.
54+
55+
The possibilities are limitless.
56+
57+
## Conclusion
58+
59+
Use [staticman](https://staticman.net/). It's the best all round option. Keep control of your content. If their service goes down, you keep your comments. You can run your own instance later if necessary. It includes support for akismet spam filtering.
60+
61+
**To see staticman in action, leave a comment at [Gatsby Central](https://www.gatsbycentral.com)!**

docs/blog/author.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@
105105
bio: Full-stack developer, clean code enthusiast, blogger at https://www.vojtechruzicka.com/
106106
avatar: avatars/vojtech-ruzicka.jpg
107107
twitter: "@vojtechruzicka"
108+
- id: Gatsby Central
109+
bio: The community for gatsby developers
110+
avatar: avatars/gatsby-central.jpg
111+
twitter: "@GatsbyCentral"
5.23 KB
Loading

0 commit comments

Comments
 (0)