How to add a contact form to a static site without a backend

How to add a contact form to a static site without a backend

如何在没有后端的情况下为静态网站添加联系表单

Static sites are fast, secure, and cheap to host—but they come with a catch: there’s no server to process form submissions. If you’re running a JAMstack blog, a marketing landing page, or a personal portfolio, you probably don’t want to spin up a backend just to collect a few contact messages. 静态网站速度快、安全性高且托管成本低,但它们有一个缺点:没有服务器来处理表单提交。如果你正在运营一个 JAMstack 博客、营销落地页或个人作品集,你可能不想仅仅为了收集几条联系信息就去搭建一个后端。

Yet, every modern site needs a way for visitors to get in touch. So what do you do? You basically have two options. The first is to build your own backend—set up a server, write an API endpoint, handle validation, store submissions in a database, and deal with spam protection yourself. That works, but it’s overkill for most small projects and adds ongoing maintenance you probably don’t need. 然而,每个现代网站都需要一种让访客联系你的方式。那么该怎么办呢?你基本上有两个选择。第一个是构建自己的后端——设置服务器、编写 API 接口、处理验证、将提交内容存储在数据库中,并亲自处理垃圾邮件防护。这确实可行,但对于大多数小型项目来说有些大材小用,而且会增加你本不需要的持续维护工作。

The second option is to use a form backend service that handles everything for you. This is where FormsList comes in. With FormsList, adding a contact form to any static site is literally a five-line HTML form. No JavaScript frameworks, no build steps, no configuration files. Just point your form’s action attribute to your unique FormsList endpoint, and you’re done. 第二个选择是使用为你处理一切的表单后端服务。这就是 FormsList 的用武之地。使用 FormsList,为任何静态网站添加联系表单实际上只需要一个五行的 HTML 表单。无需 JavaScript 框架,无需构建步骤,无需配置文件。只需将表单的 action 属性指向你唯一的 FormsList 接口地址,就大功告成了。

Here’s what it looks like: 以下是代码示例:

<form action="https://formslist.com/f/YOUR_ENDPOINT" method="POST">
  <input type="text" name="name" placeholder="Your name" required />
  <input type="email" name="email" placeholder="Your email" required />
  <textarea name="message" placeholder="Your message" required></textarea>
  <button type="submit">Send</button>
</form>

Spam is the silent killer of contact forms, but FormsList makes protection trivial. In about 30 seconds, you can enable a honeypot field and Akismet filtering from your dashboard. The honeypot hides a field from real users but traps bots that fill it out. Akismet adds machine-learning-powered spam detection on top. Both are optional, but turning them on takes one click each—and you’ll thank yourself later. 垃圾邮件是联系表单的隐形杀手,但 FormsList 让防护变得轻而易举。在大约 30 秒内,你就可以从仪表板启用“蜜罐”(honeypot)字段和 Akismet 过滤功能。蜜罐对真实用户隐藏,但会诱捕填写它的机器人。Akismet 则提供了基于机器学习的额外垃圾邮件检测。两者都是可选的,但只需点击一下即可开启——以后你会庆幸自己这么做了。

If you’re building static sites and need a lightweight way to collect form submissions, give FormsList a try. It’s free to get started and scales with you as your project grows. 如果你正在构建静态网站,并且需要一种轻量级的方式来收集表单提交内容,不妨试试 FormsList。它免费上手,并能随着你项目的增长而扩展。

Get started for free on FormsList. 立即在 FormsList 免费开始使用。