This post requires authentication to view. Please log in to continue.
This starter includes a built-in comment system, thanks to my friend Mustofa-ID for helping me set it up. The comment system uses Supabase as the database.
Here we go
Create a Supabase Account
First, create an account on Supabase.
Create a New Project
Once logged in, create a new project with the name of your website.
Create a Table for Comments
In the Supabase dashboard, go to SQL Editor and run the following query to create the comments table:
create table comments (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
name character varying not null,
email character varying null,
description text null,
slug character varying not null,
hidden boolean null,
constraint comments_pkey primary key (id)
);
alter table comments add column reply_to bigint references comments (id);
create table verified_users (email varchar unique not null);
create view comments_view as
select
c.id,
c.slug,
c.name,
c.description,
c.reply_to,
c.created_at,
v.email is not null verified
from comments c
left join verified_users v on v.email = c.email
where (c.hidden is null or c.hidden = false);
Run the Query
Copy the query into the editor and click the Run button. This will create the comments table.
Create Policies
Set up policies to allow users to insert and view comments. Run the following queries in the SQL Editor:
create policy "Enable insert with email check"
on comments as permissive for insert to anon
with check (email not in (select email from verified_users));
create policy "Allow select for all users"
on comments for select
using (hidden = false);
alter policy "Allow select for authenticated users only"
on verified_users
to authenticated using (true);
Get Supabase Project URL and API Key
In your Supabase dashboard, go to Project Settings > API.
Here, you will find the Project URL and API Key (anon public).
Create an .env File
Create a .env file in your deployment provider (such as GitHub Pages, Netlify, etc.), and add the following variables:
SUPABASE_URL=https://your-project-url.supabase.co
SUPABASE_KEY=your-anon-public-api-key
Local Development
You can also create a .env file for local development, but avoid hard-coding the values directly into your code.
If you want to modify the comment layout, simply check the files _include/js/comment.js and _include/post/comment.html.
Please note that you need to manually update the hidden column value for each new comment in Supabase. A value of false means the comment will be displayed on your website.
I havenβt figured out how to set up email notifications yet, but Iβll work on it and write a post about it once I do.
That's it! Your comment system is now configured. Have any question?
Β© 2025 Jake B. Macale