Anocus is a reusable anonymous comment component for static sites.
It provides:
- Anonymous comments (no GitHub login required for visitors)
- Threaded replies (comment reply)
- Cloudflare Turnstile human verification
- Pluggable storage backends
github: GitHub Discussionskv: Cloudflare KV- Cloudflare Pages Functions adapter
client/anocus.js+client/anocus.css: embeddable frontend widgetserver/*: validation, anti-spam, storage adaptersadapters/cloudflare.ts: request handlers for Pages Functionstemplates/*: copy-ready integration templates
This is a source-first integration, no build step required.
Copy these files into your static assets:
client/anocus.js->static/anocus/anocus.jsclient/anocus.css->static/anocus/anocus.css
Create:
functions/api/anocus/thread.tsfunctions/api/anocus/comment.ts
Use the templates from:
templates/cloudflare/functions/api/anocus/thread.tstemplates/cloudflare/functions/api/anocus/comment.ts
If you keep Anocus source in your repo (recommended), make imports point to your local copy of adapters/cloudflare.ts.
Use template:
templates/hugo/layouts/partials/comments.html
Then render it from your single post template.
[params.anocus]
enabled = true
api_base = '/api/anocus'
turnstile_site_key = 'YOUR_TURNSTILE_SITE_KEY'
max_length = 5000
lang = 'en'Required for all backends:
ANOCUS_STORAGE_BACKEND=githuborkvANOCUS_ALLOWED_ORIGIN=https://example.comANOCUS_TURNSTILE_SECRET_KEY
Optional anti-spam controls:
ANOCUS_MAX_COMMENT_LENGTH(default5000)ANOCUS_MIN_SECONDS_BETWEEN_POSTS(default20)ANOCUS_MAX_POSTS_PER_HOUR(default20)
GitHub backend:
ANOCUS_GITHUB_TOKENANOCUS_GITHUB_REPO_OWNERANOCUS_GITHUB_REPO_NAMEANOCUS_GITHUB_CATEGORY_IDorANOCUS_GITHUB_CATEGORY_NAME
KV backend:
- Bind KV namespace as
ANOCUS_KV
Returns:
- provider
- thread metadata (or
nullif not found yet) - normalized comment list
Body:
{
"pathname": "/post/path",
"page_title": "Post title",
"guest_name": "Alice",
"guest_link": "https://example.com",
"content": "Hello",
"parent_comment_id": "optional_parent_comment_id",
"turnstile_token": "..."
}- Turnstile token is verified server-side.
- Only comments using the Anocus public format header (
[Anocus Comment]) are displayed. - Request origin can be restricted with
ANOCUS_ALLOWED_ORIGIN. - In-memory rate limits reduce spam bursts.
By default, new comments are written to storage with a visible header block:
Name: ...Link: ...(if provided)---
MIT