Say Goodbye to Disqus! 👋
How to build a free, private, and customizable comment system.
Introduction
Build our own “Local” Comment System using Supabase (Backend) and some simple JavaScript (Frontend).
It supports:
- Privacy (You own the data)
- Nested Replies (Like Reddit!)
- Custom Themes (Match your website colors)
- 100% Free (Supabase Free Tier)
Let’s dive in! 🛠️
Step 1: Backend Setup (Supabase)
First, we need a place to store the comments.
- Go to Supabase.com and create a New Project.
- Go to the SQL Editor (the sidebar icon that looks like terminal code).
- Copy & Paste the code below to set up your database instantly.
SQL The Magic Of Building
1 | -- 1. (OPTIONAL) Reset: Drop the table so we can rebuild it correctly |
Once you run this, in Supabase, go to
Project Settings > Data API get yourProject URL.
Project Settings > API Keys > Legacy anon, service_role API keys get youranon public key
💡 Pro Tip:
The URL: It is Public. It is essentially the address of your database. It is safe to be seen.
The anon (public) key: It is safe to publish, provided you have set up Row Level Security (RLS).
Step 2: Frontend Integration
1. Create the Component
Create a new file at: themes/your-theme/layout/_partial/supabase-comments.ejs
Download the exmaple supabase-comments.ejs: supabase-comments.ejs
2. Configuration
Open themes/your-theme/_config.yml and add this at the bottom:
1 | # Supabase Comments Configuration |
3. Add to Blog
Now, open your Post Layout .ejs file (usually themes/your-theme/layout/post.ejs or _partial/article.ejs or themes/your-theme/layout/post-detailed.ejs).
Add this code where you want the comments to appear (usually at the bottom):
1 | <% if (theme.supabase.enable) { %> |
Step 3: Deployment
Test Locally
1 | hexo clean && hexo g && hexo s |
Deploy
1 | hexo clean && hexo g && hexo d |
1 | # (Optional) Install git deployer if you haven't yet |
CONGRATULATION!
Now you have a comment system that is fully yours. No ads, no tracking, just pure community interaction.
If you have any questions, feel free to leave a comment below… using the system we just built!
Discussion