Forms — Kendi HTML
The Kendi HTML template has two forms, and they send to the form service or webhook of your choice: the contact form and the newsletter sign-up.
The newsletter appears in three places: Home’s hero, the sidebar’s “Newsletter” card (Home and every post) and the “Stay updated with our letter” band above the footer (every page but the legal pages and the 404). The contact form is on Contact. Each form checks the required fields, shows a spinner while sending, says “Thank you” and clears the fields, keeps what the visitor typed when something fails (“Something went wrong”), and drops spam with a hidden honeypot field.
Out of the box they run in demo mode: nothing is sent, and the fields are logged in the browser console. Pick a destination before you publish.
Connect a form service
Section titled “Connect a form service”A static site has no server of its own, so submissions go to a form service or a webhook. All of these have a free tier:
| Service | What it does | formEndpoint |
|---|---|---|
| Formspree | Emails you each submission | https://formspree.io/f/<form id> |
| Web3Forms | Emails you each submission, no account needed | https://api.web3forms.com/submit, and your key in formAccessKey |
| Getform, Basin | Inbox, email, integrations | The form’s endpoint URL |
| Zapier, Make, n8n, Pipedream | Send submissions anywhere: Mailchimp, Brevo, Beehiiv or another newsletter tool, Google Sheets, Slack | The webhook (“catch hook”) URL |
For a newsletter, a webhook that adds each sign-up to your newsletter tool is the usual choice; route the contact
messages by form to your inbox in the same scenario.
-
Create a form at the service and copy its endpoint.
-
Open
assets/js/config.jsand paste it:window.siteConfig = {formEndpoint: "https://formspree.io/f/abcdwxyz",formAccessKey: "", // Web3Forms only}; -
Serve the folder (
npx serve .), submit each form (a newsletter sign-up from Home, the sidebar and the band, a contact message) and check that the submissions arrived. -
Upload
config.jswith the site.
Every page loads the same config.js, so one endpoint serves both forms. The sample forms in style-guide.html stay in
demo mode whatever you set there (they carry data-form-demo), so they never send anything.
What the service receives
Section titled “What the service receives”Each field by its name, as multipart/form-data, plus form and subject, which tell the forms apart.
The newsletter (form: newsletter, subject “New newsletter subscriber”, button “Subscribe”):
| Field | Name | Required |
|---|---|---|
email |
yes | |
| The consent box (the sidebar card and the band only) | consent (on when ticked, absent otherwise) |
The contact form on Contact (form: contact, subject “New contact message”, button “Submit”):
| Field | Name | Required |
|---|---|---|
| Name | Name |
yes |
Email |
yes | |
| Message | Message |
yes |
An e-mail that doesn’t look like an address shows the error without sending. If the service answers with an error, the form shows “Something went wrong” and keeps what was typed.
Changing the fields
Section titled “Changing the fields”The forms are plain HTML in the pages: a <form data-form> on Contact, a <form data-newsletter> in each newsletter
box. Their messages are attributes of the form (data-success="Thank you", data-error="Something went wrong",
data-submit-label="Submit"), and each field is a <label> holding its text and an <input> or <textarea>.
- To make a field optional, remove
requiredfrom its<input>or<textarea>. The submit button stays faded until every required field is filled. - To add a field, copy a
<label>…</label>block of the contact form, and change its text, thename, theplaceholderand thetype(text,email,tel), or copy the message’s block for another text area. - To remove a field, delete its
<label>block. - Keep the hidden
formandsubjectinputs, and don’t give a real field the namefax: it is the honeypot’s (Spam and privacy).
The newsletter boxes are copied into many pages (the band into every page with one, the sidebar card into Home and every post): change a newsletter box with find and replace in files (Editing the site).
Testing before launch
Section titled “Testing before launch”- Submit each form on your own site after uploading, with a real address, and check the destination.
- Reply to the test message.
- Try a failure on purpose: a wrong endpoint, submit, and confirm the visitor sees “Something went wrong” and their text is still there.
Spam and privacy
Section titled “Spam and privacy”The honeypot stops the usual bots: every form carries a hidden field named fax that a person never sees; a bot that
fills it is shown “Thank you” and nothing is sent. Form services filter spam on their side too; turn on their captcha if
spam still gets through.
Submissions go only to the endpoint you set; the site itself stores nothing. The newsletter boxes in the sidebar and the
band carry a consent line that links your Terms of Service and Privacy Policy; Home’s hero box has none. The legal texts
are generic samples with placeholders ([Your Company Name] …): fill them in and make the Privacy Policy say how you
handle subscribers and messages, and which form service receives them (Editing the site). If your
newsletter tool supports double opt-in, turn it on: it is the safest way to collect consent to send.